Dam*_*ell 13 msbuild csproj visual-studio
我的解决方案中有一个项目,它起源于C#库项目.它在代码方面对它没有任何兴趣,它只是在我的解决方案中用作其他项目的依赖项,以确保它是首先构建的.构建此项目的一个副作用是创建一个共享的AssemblyInfo.cs,其中包含其他项目正在使用的版本号.
我通过在.csproj文件中添加以下内容来完成此操作:
<ItemGroup>
<None Include="Properties\AssemblyInfo.Shared.cs.in" />
<Compile Include="Properties\AssemblyInfo.Shared.cs" />
<None Include="VersionInfo.targets" />
</ItemGroup>
<Import Project="$(ProjectDir)VersionInfo.targets" />
<Target Name="BeforeBuild" DependsOnTargets="UpdateSharedAssemblyInfo" />
Run Code Online (Sandbox Code Playgroud)
引用的文件VersionInfo.targets包含以下内容:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--
Some properties defining tool locations and the name of the
AssemblyInfo.Shared.cs.in file etc.
-->
</PropertyGroup>
<Target Name="UpdateSharedAssemblyInfo">
<!--
Uses the Exec task to run one of the tools to generate
AssemblyInfo.Shared.cs based on the location of AssemblyInfo.Shared.cs.in
and some of the other properties.
-->
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud)
VersionInfo.targets文件的内容可以简单地嵌入.csproj文件中,但它是外部的,因为我试图将所有这些内容转换为项目模板.我希望模板的用户能够将新项目添加到解决方案,编辑VersionInfo.targets文件,然后运行构建.
问题是修改和保存VersionInfo.targets文件并重建解决方案没有任何效果 - 项目文件使用.targets文件中的值,就像打开项目时一样.即使卸载和重新加载项目也没有效果.为了获得新值,我需要关闭Visual Studio并重新打开它(或重新加载解决方案).
如何设置它以使配置在.csproj文件外部而不在构建之间缓存?
| 归档时间: |
|
| 查看次数: |
5845 次 |
| 最近记录: |