Fix some template issues and modified mpf a bit.

This commit is contained in:
Charles Betros 2017-04-11 11:25:24 -05:00
parent 40d1382c4f
commit bf7c30e69c
8 changed files with 146 additions and 102 deletions

View file

@ -25,7 +25,10 @@
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort> <VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include=".\$KernelName$.$ProjectTypeExtension$" /> <ProjectReference Include=".\$KernelProjectName$.$ProjectTypeExtension$">
<Name>$KernelProjectName$</Name>
<Project>$KernelProjectGuid$</Project>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Cosmos.Core.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983"/> <Reference Include="Cosmos.Core.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983"/>

View file

@ -1,6 +1,8 @@
<Project Sdk="Microsoft.Net.Sdk"> <Project Sdk="Microsoft.Net.Sdk">
<PropertyGroup> <PropertyGroup>
<AssemblyName>$KernelProjectName$</AssemblyName>3
<ProjectGuid>$KernelProjectGuid$</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
</PropertyGroup> </PropertyGroup>

View file

@ -1,6 +1,8 @@
<Project Sdk="Microsoft.Net.Sdk"> <Project Sdk="Microsoft.Net.Sdk">
<PropertyGroup> <PropertyGroup>
<AssemblyName>$KernelProjectName$</AssemblyName>
<ProjectGuid>$KernelProjectGuid$</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
</PropertyGroup> </PropertyGroup>

View file

@ -25,7 +25,10 @@
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort> <VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include=".\$KernelName$.$ProjectTypeExtension$" /> <ProjectReference Include=".\$KernelProjectName$.$ProjectTypeExtension$">
<Name>$KernelProjectName$</Name>
<Project>$KernelProjectGuid$</Project>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Cosmos.Core.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983"/> <Reference Include="Cosmos.Core.Plugs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5ae71220097cb983"/>

View file

@ -60,6 +60,7 @@ using MSBuild = Microsoft.Build.Evaluation;
using MSBuildExecution = Microsoft.Build.Execution; using MSBuildExecution = Microsoft.Build.Execution;
using Microsoft.Build.Evaluation; using Microsoft.Build.Evaluation;
using Microsoft.Build.Framework; using Microsoft.Build.Framework;
using Microsoft.Build.Execution;
namespace Microsoft.VisualStudio.Project namespace Microsoft.VisualStudio.Project
{ {
@ -378,71 +379,52 @@ namespace Microsoft.VisualStudio.Project
private void SetHintPathAndPrivateValue() private void SetHintPathAndPrivateValue()
{ {
// Private means local copy; we want to know if it is already set to not override the default
string privateValue = this.ItemNode.GetMetadata(ProjectFileConstants.Private);
// Get the list of items which require HintPath
ICollection<ProjectItemInstance> references = this.ProjectMgr.CurrentConfig.GetItems(MsBuildGeneratedItemType.ReferenceCopyLocalPaths);
// Remove the HintPath, we will re-add it below if it is needed // Remove the HintPath, we will re-add it below if it is needed
if(!String.IsNullOrEmpty(this.assemblyPath)) if(!String.IsNullOrEmpty(this.assemblyPath))
{ {
this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, null); this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, null);
} }
// Get the list of items which require HintPath
IEnumerable<MSBuild.ProjectItem> references = this.ProjectMgr.BuildProject.GetItems(MsBuildGeneratedItemType.ReferenceCopyLocalPaths);
// Now loop through the generated References to find the corresponding one // Now loop through the generated References to find the corresponding one
foreach (MSBuild.ProjectItem reference in references) foreach (ProjectItemInstance reference in references)
{ {
string fileName = Path.GetFileNameWithoutExtension(reference.EvaluatedInclude); string fileName = Path.GetFileNameWithoutExtension(reference.EvaluatedInclude);
if(String.Compare(fileName, this.assemblyName.Name, StringComparison.OrdinalIgnoreCase) == 0) if(String.Compare(fileName, this.assemblyName.Name, StringComparison.OrdinalIgnoreCase) == 0)
{ {
// We found it, now set some properties based on this. // We found it, now set some properties based on this.
string hintPath = reference.GetMetadataValue(ProjectFileConstants.HintPath); string hintPath = reference.GetMetadataValue(ProjectFileConstants.HintPath);
this.SetHintPathAndPrivateValue(hintPath); if (!string.IsNullOrEmpty(hintPath))
{
if(Path.IsPathRooted(hintPath))
{
hintPath = PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, new Uri(hintPath));
}
this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, hintPath);
// If this is not already set, we default to true
if(String.IsNullOrEmpty(privateValue))
{
this.ItemNode.SetMetadata(ProjectFileConstants.Private, true.ToString());
}
}
break; break;
} }
} }
} }
/// <summary>
/// Sets the hint path to the provided value.
/// It also sets the private value to true if it has not been already provided through the associated project element.
/// </summary>
/// <param name="hintPath">The hint path to set.</param>
private void SetHintPathAndPrivateValue(string hintPath)
{
if (String.IsNullOrEmpty(hintPath))
{
return;
}
if (Path.IsPathRooted(hintPath))
{
hintPath = PackageUtilities.GetPathDistance(this.ProjectMgr.BaseURI.Uri, new Uri(hintPath));
}
this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, hintPath);
// Private means local copy; we want to know if it is already set to not override the default
string privateValue = this.ItemNode != null ? this.ItemNode.GetMetadata(ProjectFileConstants.Private) : null;
// If this is not already set, we default to true
if (String.IsNullOrEmpty(privateValue))
{
this.ItemNode.SetMetadata(ProjectFileConstants.Private, true.ToString());
}
}
/// <summary> /// <summary>
/// This function ensures that some properties of the reference are set. /// This function ensures that some properties of the reference are set.
/// </summary> /// </summary>
private void SetReferenceProperties() private void SetReferenceProperties()
{ {
// If there is an assembly path then just set the hint path
if (!string.IsNullOrEmpty(this.assemblyPath))
{
this.SetHintPathAndPrivateValue(this.assemblyPath);
return;
}
// Set a default HintPath for msbuild to be able to resolve the reference. // Set a default HintPath for msbuild to be able to resolve the reference.
this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, this.assemblyPath); this.ItemNode.SetMetadata(ProjectFileConstants.HintPath, this.assemblyPath);
@ -454,10 +436,11 @@ namespace Microsoft.VisualStudio.Project
} }
// Check if we have to resolve again the path to the assembly. // Check if we have to resolve again the path to the assembly.
this.ResolveReference(); if (!string.IsNullOrEmpty(this.assemblyPath))
{
// Make sure that the hint path if set (if needed). ResolveReference();
this.SetHintPathAndPrivateValue(); SetHintPathAndPrivateValue();
}
} }
/// <summary> /// <summary>

View file

@ -130,6 +130,11 @@ namespace Microsoft.VisualStudio.Project
/// <returns>An instance of a ProjectConfig object.</returns> /// <returns>An instance of a ProjectConfig object.</returns>
protected ProjectConfig GetProjectConfiguration(string configName) protected ProjectConfig GetProjectConfiguration(string configName)
{ {
if (configName == null)
{
return null;
}
// if we already created it, return the cached one // if we already created it, return the cached one
if(configurationsList.ContainsKey(configName)) if(configurationsList.ContainsKey(configName))
{ {

View file

@ -336,6 +336,8 @@ namespace Microsoft.VisualStudio.Project
{ {
// NOTE: This may run on a background thread! // NOTE: This may run on a background thread!
QueueOutputEvent(messageEvent.Importance, messageEvent); QueueOutputEvent(messageEvent.Importance, messageEvent);
if(messageEvent.Importance == MessageImportance.High)
QueueTaskEvent(messageEvent);
} }
#endregion #endregion
@ -449,6 +451,12 @@ namespace Microsoft.VisualStudio.Project
task.Column = warningArgs.ColumnNumber; task.Column = warningArgs.ColumnNumber;
task.Priority = TaskPriority.Normal; task.Priority = TaskPriority.Normal;
} }
else if (errorEvent is BuildMessageEventArgs)
{
BuildMessageEventArgs messageArgs = (BuildMessageEventArgs)errorEvent;
task.ErrorCategory = TaskErrorCategory.Message;
task.Priority = TaskPriority.Normal;
}
task.Text = errorEvent.Message; task.Text = errorEvent.Message;
task.Category = TaskCategory.BuildCompile; task.Category = TaskCategory.BuildCompile;
@ -509,7 +517,7 @@ namespace Microsoft.VisualStudio.Project
/// <summary> /// <summary>
/// This method takes a MessageImportance and returns true if messages /// This method takes a MessageImportance and returns true if messages
/// at importance i should be loggeed. Otherwise return false. /// at importance i should be logged. Otherwise return false.
/// </summary> /// </summary>
private bool LogAtImportance(MessageImportance importance) private bool LogAtImportance(MessageImportance importance)
{ {

View file

@ -174,61 +174,8 @@ namespace Microsoft.VisualStudio.Project
{ {
return null; return null;
} }
foreach (EnvDTE.Project prj in dte.Solution.Projects)
{
//Skip this project if it is an umodeled project (unloaded)
if (string.Compare(EnvDTE.Constants.vsProjectKindUnmodeled, prj.Kind, StringComparison.OrdinalIgnoreCase) == 0)
{
continue;
}
// Get the full path of the current project. this.referencedProject = this.FindReferencedProject(dte.Solution.Projects);
EnvDTE.Property pathProperty = null;
try
{
if (prj.Properties == null)
{
continue;
}
pathProperty = prj.Properties.Item("FullPath");
if (null == pathProperty)
{
// The full path should alway be availabe, but if this is not the
// case then we have to skip it.
continue;
}
}
catch (ArgumentException)
{
continue;
}
string prjPath = pathProperty.Value.ToString();
EnvDTE.Property fileNameProperty = null;
// Get the name of the project file.
try
{
fileNameProperty = prj.Properties.Item("FileName");
if (null == fileNameProperty)
{
// Again, this should never be the case, but we handle it anyway.
continue;
}
}
catch (ArgumentException)
{
continue;
}
prjPath = System.IO.Path.Combine(prjPath, fileNameProperty.Value.ToString());
// If the full path of this project is the same as the one of this
// reference, then we have found the right project.
if (NativeMethods.IsSamePath(prjPath, referencedProjectFullPath))
{
this.referencedProject = prj;
break;
}
}
} }
return this.referencedProject; return this.referencedProject;
@ -554,6 +501,97 @@ namespace Microsoft.VisualStudio.Project
return circular != 0; return circular != 0;
} }
private EnvDTE.Project FindReferencedProject(System.Collections.IEnumerable projects)
{
EnvDTE.Project refProject = null;
// Search for the project in the collection of the projects in the current solution.
foreach (EnvDTE.Project prj in projects)
{
//Skip this project if it is an umodeled project (unloaded)
if (string.Compare(EnvDTE.Constants.vsProjectKindUnmodeled, prj.Kind, StringComparison.OrdinalIgnoreCase) == 0)
{
continue;
}
// Recursively iterate solution folder for the project.
if (string.Compare(EnvDTE.Constants.vsProjectKindSolutionItems, prj.Kind, StringComparison.OrdinalIgnoreCase) == 0)
{
var containedProjects = GetContainerProjects(prj);
refProject = FindReferencedProject(containedProjects);
if (refProject != null)
return refProject;
}
// Get the full path of the current project.
EnvDTE.Property pathProperty = null;
try
{
if (prj.Properties == null)
{
continue;
}
pathProperty = prj.Properties.Item("FullPath");
if (null == pathProperty)
{
// The full path should alway be availabe, but if this is not the
// case then we have to skip it.
continue;
}
}
catch (ArgumentException)
{
continue;
}
string prjPath = pathProperty.Value.ToString();
EnvDTE.Property fileNameProperty = null;
// Get the name of the project file.
try
{
fileNameProperty = prj.Properties.Item("FileName");
if (null == fileNameProperty)
{
// Again, this should never be the case, but we handle it anyway.
continue;
}
}
catch (ArgumentException)
{
continue;
}
prjPath = System.IO.Path.Combine(prjPath, fileNameProperty.Value.ToString());
// If the full path of this project is the same as the one of this
// reference, then we have found the right project.
if (NativeMethods.IsSamePath(prjPath, referencedProjectFullPath))
{
refProject = prj;
break;
}
}
return refProject;
}
private static System.Collections.IEnumerable GetContainerProjects(EnvDTE.Project prj)
{
foreach (var obj in prj.ProjectItems)
{
var pi = obj as EnvDTE.ProjectItem;
if (pi == null)
{
continue;
}
var nestedPrj = pi.Object as EnvDTE.Project;
if (nestedPrj != null)
{
yield return nestedPrj;
}
}
}
#endregion #endregion
} }