This commit is contained in:
mterwoord_cp 2010-08-10 08:48:37 +00:00
parent 54cecd7648
commit cbfe4c0a8e
11 changed files with 178 additions and 35 deletions

View file

@ -74,6 +74,10 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0" />
<Reference Include="Microsoft.VisualStudio.TemplateWizardInterface, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.TemplateWizardInterface.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.9.0" />
<Reference Include="System" />
@ -132,6 +136,8 @@
<Compile Include="SubPropertyPageBase.Designer.cs">
<DependentUpon>SubPropertyPageBase.cs</DependentUpon>
</Compile>
<Compile Include="Templates\GenerateGuidsWizard.cs" />
<Compile Include="Templates\UseGuidsWizard.cs" />
<Compile Include="TitleDivision.cs">
<SubType>UserControl</SubType>
</Compile>
@ -168,6 +174,7 @@
<None Include="Key.snk" />
<Content Include="PLKResponse.html" />
<Content Include="Resources\Cosmos.ico" />
<Content Include="Templates\Projects\CosmosProject %28C#%29\Readme.txt" />
<ZipItem Include="Templates\Projects\CosmosProject %28C#%29\CosmosProject.vstemplate">
<RootPath>Templates\Projects\CosmosProject %28C#%29</RootPath>
</ZipItem>

View file

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TemplateWizard;
namespace Cosmos.VS.Package.Templates.Wizards
{
public class GenerateGuidsWizard: IWizard
{
public static Guid? Guid1 = null;
public static Guid? Guid2 = null;
public void BeforeOpeningFile(EnvDTE.ProjectItem projectItem)
{
}
public void ProjectFinishedGenerating(EnvDTE.Project project)
{
}
public void ProjectItemFinishedGenerating(EnvDTE.ProjectItem projectItem)
{
}
public void RunFinished()
{
}
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
Guid1 = Guid.NewGuid();
Guid2 = Guid.NewGuid();
replacementsDictionary.Add("$GeneratedGuid1$", GenerateGuidsWizard.Guid1.Value.ToString("B"));
replacementsDictionary.Add("$GeneratedGuid2$", GenerateGuidsWizard.Guid2.Value.ToString("B"));
}
public bool ShouldAddProjectItem(string filePath)
{
return true;
}
}
}

View file

@ -8,17 +8,12 @@
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$safeprojectname$">
Proj\CosmosProj.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$Kernel">
ProjKernel\CSharpProj.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$">
Proj\CosmosProj.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
<CustomParameters>
<CustomParameter Name="guid1" Value="$guid1$"/>
<CustomParameter Name="guid2" Value="$guid2$"/>
<CustomParameter Name="kernelname" Value="$safeprojectname$"/>
</CustomParameters>
</TemplateContent>
</VSTemplate>

View file

@ -14,4 +14,8 @@
<TemplateContent>
<Project File="CosmosProject.Cosmos" ReplaceParameters="true"/>
</TemplateContent>
<WizardExtension>
<Assembly>Cosmos.VS.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f4d94ac959d59ec3</Assembly>
<FullClassName>Cosmos.VS.Package.Templates.Wizards.UseGuidsWizard</FullClassName>
</WizardExtension>
</VSTemplate>

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>$guid1$</ProjectGuid>
<ProjectGuid>$GeneratedGuid1$</ProjectGuid>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<Name>$safeprojectname$</Name>
<BinFormat>elf</BinFormat>
@ -19,7 +19,6 @@
<VMWareFlavor>Player</VMWareFlavor>
<StartCosmosGDB>false</StartCosmosGDB>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Release\</OutputPath>
@ -35,8 +34,7 @@
<ItemGroup>
<ProjectReference Include="..\$safeprojectname$Kernel\$safeprojectname$Kernel.csproj">
<Name>$safeprojectname$Kernel</Name>
<Project>$guid2$</Project>
<Private>True</Private>
<Project>$GeneratedGuid2$</Project>
</ProjectReference>
</ItemGroup>

View file

@ -1,19 +1,23 @@
<VSTemplate Version="2.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>ProjKernel</Name>
<Description>A project for creating a Cosmos Kernel</Description>
<Icon>Kernel.ico</Icon>
<ProjectType>CSharp</ProjectType>
<!--<SortOrder>50</SortOrder>
<TemplateData>
<Name>ProjKernel</Name>
<Description>A project for creating a Cosmos Kernel</Description>
<Icon>Kernel.ico</Icon>
<ProjectType>CSharp</ProjectType>
<!--<SortOrder>50</SortOrder>
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>CosmosProjectKernel</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>-->
</TemplateData>
<TemplateContent>
<Project File="CSharpProject.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="true">AssemblyInfo.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" OpenInEditor="true">Kernel.cs</ProjectItem>
</Project>
</TemplateContent>
</TemplateData>
<TemplateContent>
<Project File="CSharpProject.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="true">AssemblyInfo.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" OpenInEditor="true">Kernel.cs</ProjectItem>
</Project>
</TemplateContent>
<WizardExtension>
<Assembly>Cosmos.VS.Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f4d94ac959d59ec3</Assembly>
<FullClassName>Cosmos.VS.Package.Templates.Wizards.GenerateGuidsWizard</FullClassName>
</WizardExtension>
</VSTemplate>

View file

@ -5,11 +5,11 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>$guid2$</ProjectGuid>
<ProjectGuid>$GeneratedGuid2$</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>$kernelname$Kernel</RootNamespace>
<AssemblyName>$kernelname$Kernel</AssemblyName>
<RootNamespace>$safeprojectname$</RootNamespace>
<AssemblyName>$safeprojectname$</AssemblyName>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

View file

@ -0,0 +1,2 @@
$GeneratedGuid1$ .Cosmos id
$GeneratedGuid2$ .csproj id

View file

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TemplateWizard;
namespace Cosmos.VS.Package.Templates.Wizards
{
public class UseGuidsWizard: IWizard
{
public void BeforeOpeningFile(EnvDTE.ProjectItem projectItem)
{
}
public void ProjectFinishedGenerating(EnvDTE.Project project)
{
}
public void ProjectItemFinishedGenerating(EnvDTE.ProjectItem projectItem)
{
}
public void RunFinished()
{
}
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
replacementsDictionary.Add("$GeneratedGuid1$", GenerateGuidsWizard.Guid1.Value.ToString("B"));
replacementsDictionary.Add("$GeneratedGuid2$", GenerateGuidsWizard.Guid2.Value.ToString("B"));
GenerateGuidsWizard.Guid1 = null;
GenerateGuidsWizard.Guid2 = null;
}
public bool ShouldAddProjectItem(string filePath)
{
return true;
}
}
}

View file

@ -528,14 +528,14 @@ namespace Microsoft.VisualStudio.Project
return false;
}
IVsHierarchy hierarchy = null;
//IVsHierarchy hierarchy = null;
hierarchy = VsShellUtilities.GetHierarchy(this.ProjectMgr.Site, this.referencedProjectGuid);
if(hierarchy == null)
{
return false;
}
// MtW: this code has been disabled, fixes dependency and reference resolving issues.
//hierarchy = VsShellUtilities.GetHierarchy(this.ProjectMgr.Site, this.referencedProjectGuid);
//if(hierarchy == null)
//{
// return false;
//}
//If the Project is unloaded return false
if(this.ReferencedProjectObject == null)

View file

@ -5,6 +5,8 @@ using System.Diagnostics;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using IServiceProvider = System.IServiceProvider;
using Cosmos.VS.Package;
using Microsoft.VisualStudio.Project.Automation;
namespace Microsoft.VisualStudio.Project
{
@ -12,6 +14,51 @@ namespace Microsoft.VisualStudio.Project
[CLSCompliant(false)]
public class SolutionListenerForProjectOpen : SolutionListener
{
public static string GetDisplayNameForHierarch(IVsHierarchy hierarchy)
{
if (hierarchy == null)
{
return "Hierarchy == null";
}
object xValue;
hierarchy.GetProperty(0xfffffffe, (int)__VSHPROPID.VSHPROPID_EditLabel, out xValue);
return (string)xValue;
}
internal static EnvDTE.Project GetProject(IVsHierarchy hierarchy)
{
object project;
ErrorHandler.ThrowOnFailure(
hierarchy.GetProperty(
VSConstants.VSITEMID_ROOT,
(int)__VSHPROPID.VSHPROPID_ExtObject,
out project
)
);
return (project as EnvDTE.Project);
}
public static VSProjectNode GetCommonProject(EnvDTE.Project project)
{
OAProject oaProj = project as OAProject;
if (oaProj != null)
{
var common = oaProj.Project as VSProjectNode;
if (common != null)
{
return common;
}
}
return null;
}
internal static VSProjectNode GetVSProject(EnvDTE.Project project)
{
return GetCommonProject(project) as VSProjectNode;
}
public SolutionListenerForProjectOpen(IServiceProvider serviceProvider)
: base(serviceProvider)
{
@ -19,6 +66,8 @@ namespace Microsoft.VisualStudio.Project
public override int OnAfterOpenProject(IVsHierarchy hierarchy, int added)
{
// If this is a new project and our project. We use here that it is only our project that will implemnet the "internal" IBuildDependencyOnProjectContainer.
if(added != 0 && hierarchy is IBuildDependencyUpdate)
{