将自定义msbuild目标从解决方案传递到项目 [英] Pass custom msbuild target from Solution to Project
本文介绍了将自定义msbuild目标从解决方案传递到项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含大量相关.csproj文件的解决方案.
I have a Solution with a large number of associated .csproj files.
每个.csproj文件都有一个<Target Name="PublishQA">...
.
Each .csproj file has a <Target Name="PublishQA">...
.
当我尝试编译整个解决方案时,构建失败:
The build fails when I try to compile the whole solution:
> msbuild mysolution.sln /t:PublishQA`
"c:\myproj.sln" (publishqa target) (1) ->
c:\myproj.sln.metaproj : error MSB4057: The target "PublishQA" does not exist in the project. [c:\myproj.sln]
当我直接构建.csproj
项目时,它的构建就很好了.
When I build the .csproj
project directly, it builds just fine.
如何告诉msbuild将目标传递给项目文件?
推荐答案
作为一种情况,您可以创建单独的目标文件来明确构建您的解决方案,
As a case you can create seperate targets file which explicitly builds your solution,
<!-- mytargets.targets file -->
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="MyTargets"
InitialTargets="MyTargets">
<Target Name="MyTargets">
<MSBuild Projects="MySolution.sln" />
</Target>
</Project>
所以现在您应该可以像这样调用它
So now you should be able just calling it like
msbuild.exe mytargets.targets
msbuild.exe mytargets.targets
这篇关于将自定义msbuild目标从解决方案传递到项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文