[英]How to nest a Target within another Target in the .csproj file?
Long story short, I need to kill the VBCSCompiler.exe on a Azure pipeline Ubuntu agent after the nuget restore task is completed.长话短说,在 nuget 恢复任务完成后,我需要在 Azure 管道 Ubuntu 代理上终止 VBCSCompiler.exe。 On windows2019 agent i dont need to do that but on ubuntu i am running into an issue:
在 windows2019 代理上我不需要这样做,但在 ubuntu 上我遇到了一个问题:
/home/vsts/work/1/s/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8/build/net45/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(17,5):
warning MSB3021: Unable to copy file "/home/vsts/work/1/s/packages/Microsoft.Net.Compilers.2.4.0/build/../tools/csc.exe" to "/bin/roslyn/csc.exe". Access to the path '/bin/roslyn' is denied. [/home/vsts/work/1/s/Bobby.ProjectA/Bobby.ProjectA.csproj]
so according to Levi in this post here , I need to add a <Target Name="CheckIfShouldKillVBCSCompiler">
lines to the .csproj
file.所以根据 Levi 在这篇文章中的说法,我需要在
.csproj
文件中添加<Target Name="CheckIfShouldKillVBCSCompiler">
行。 i added them like this:我这样添加它们:
...
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target> -->
<Target Name="CheckIfShouldKillVBCSCompiler">
<PropertyGroup>
<ShouldKillVBCSCompiler>true</ShouldKillVBCSCompiler>
</PropertyGroup>
</Target>
</Project>
But that didnt do anything to unlock the /bin/roslyn
path.但这并没有做任何事情来解锁
/bin/roslyn
路径。
I am thinking that this has to be added in the BeforeBuild
target lines (eg nest them), so i attempted this:我认为这必须添加到
BeforeBuild
目标行中(例如嵌套它们),所以我尝试了这个:
<Target Name="BeforeBuild">
<Target Name="CheckIfShouldKillVBCSCompiler">
<PropertyGroup>
<ShouldKillVBCSCompiler>true</ShouldKillVBCSCompiler>
</PropertyGroup>
</Target>
</Target>
But i ended up with error: error MSB4067: The element <PropertyGroup> beneath element <Target> is unrecognized.
但我最终遇到错误:
error MSB4067: The element <PropertyGroup> beneath element <Target> is unrecognized.
Ive learned from this answer that this cannot be accomplished.我从这个答案中了解到,这是无法实现的。
The target cannot be nested in another target.目标不能嵌套在另一个目标中。 Instead, the target can be modified like this:
相反,可以像这样修改目标:
<Target Name="CheckIfShouldKillVBCSCompiler" BeforeTargets="build">
<PropertyGroup>
<ShouldKillVBCSCompiler>true</ShouldKillVBCSCompiler>
</PropertyGroup>
</Target>
However, this did not help resolve the original build issue i had.但是,这无助于解决我遇到的原始构建问题。 What did is a different approach found here
在这里找到了一种不同的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.