中午,亲爱的社区。 p>
我参与了构建包含2个项目,Web项目和silverlight项目的VSTemplate的练习。
解决方案VSTemplate:
<VSTemplate Version="2.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>[...]</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$safeprojectname$_ClientSite">
ClientSite\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$safeprojectname$_Client">
Client\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
Silverlight-Project VSTemplate:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateContent>
<Project TargetFileName="$safeprojectname$.csproj" File="Uettingen_Client.csproj" ReplaceParameters="true">
<Folder Name="dlls" TargetFolderName="dlls">
<ProjectItem ReplaceParameters="false" TargetFileName="HST.Visualization.Controls.Silverlight.dll">HST.Visualization.Controls.Silverlight.dll</ProjectItem>
[...]
</Folder>
<ProjectItem ReplaceParameters="true" TargetFileName="App.xaml">App.xaml</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="App.xaml.cs">App.xaml.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="GlobalResources.xaml">GlobalResources.xaml</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="Head.xaml">Head.xaml</ProjectItem>
[...]
<Folder Name="Properties" TargetFolderName="Properties">
<ProjectItem ReplaceParameters="true" TargetFileName="AppManifest.xml">AppManifest.xml</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
</Folder>
<Folder Name="Service References" TargetFolderName="Service References">
<Folder Name="SLAuthenticationServiceReference" TargetFolderName="SLAuthenticationServiceReference">
<ProjectItem ReplaceParameters="true" TargetFileName="configuration.svcinfo">configuration.svcinfo</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="configuration91.svcinfo">configuration91.svcinfo</ProjectItem>
[...]
</Folder>
</Folder>
<ProjectItem ReplaceParameters="true" TargetFileName="ServiceReferences.ClientConfig">ServiceReferences.ClientConfig</ProjectItem>
[...]
</Project>
</TemplateContent>
Silverlight项目文件:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
[...]
<ItemGroup>
[...]
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.ComponentModel.Composition, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
[...]
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Page1.xaml.cs">
<DependentUpon>Page1.xaml</DependentUpon>
</Compile>
[...]
<None Include="Properties\AppManifest.xml" />
<Compile Include="Properties\AssemblyInfo.cs" />
<None Include="Service References\SLAuthenticationServiceReference\configuration.svcinfo" />
<None Include="Service References\SLAuthenticationServiceReference\configuration91.svcinfo" />
[...]
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
<Page Include="Page1.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
[...]
<WCFMetadata Include="Service References\" />
<WCFMetadataStorage Include="Service References\SLAuthenticationServiceReference\" />
<Content Include="ServiceReferences.ClientConfig" />
<Page Include="SplashWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Folder Include="img\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<ProjectExtensions>
<VisualStudio xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
<SilverlightProjectProperties />
</FlavorProperties>
<UserProperties VisiWinNETProductType="VisiWin7" VisiWinNETRuntimeType="Standard" VisiWinNETVersion="7.0" VisiWinNETProjectName="$safeprojectname$" />
</VisualStudio>
</ProjectExtensions>
</Project>
我缩短了这一点,虽然它很简单,但它的工作(几乎)完美无缺。 System.Core存在问题:
编译生成的项目后,它会在App.xaml.cs的InitializeComponents();
的构造函数中的App
上抛出一个exeption:
System.Windows.Markup.XamlParseException: [Line: 0 Position: 0] ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
现在我正在检查System.Core,我意识到一些奇怪的事情:
<Reference Include="System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
或<Reference Include="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
放入Uettingen_Client.csproj而不是<Reference Include="System.Core" />
,4.0.0.0部分将错过来源<References><Reference><Assembly>System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</Assembly></Reference></References>
或<References><Reference><Assembly>System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</Assembly></Reference></References>
插入项目VSTemplate文件的TemplateContent部分。这根本不起作用,System.Core甚至没有显示为条目。有什么想法吗?