【发布时间】:2020-12-15 15:19:35
【问题描述】:
长话短说,在 nuget 还原任务完成后,我需要在 Azure 管道 Ubuntu 代理上终止 VBCSCompiler.exe。在 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]
所以根据 this post here 中的 Levi,我需要在 .csproj 文件中添加 <Target Name="CheckIfShouldKillVBCSCompiler"> 行。我是这样添加的:
...
<!-- 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>
但这并没有做任何事情来解锁/bin/roslyn 路径。
我认为这必须添加到 BeforeBuild 目标行中(例如嵌套它们),所以我尝试了这个:
<Target Name="BeforeBuild">
<Target Name="CheckIfShouldKillVBCSCompiler">
<PropertyGroup>
<ShouldKillVBCSCompiler>true</ShouldKillVBCSCompiler>
</PropertyGroup>
</Target>
</Target>
但我最终遇到了错误:
error MSB4067: The element <PropertyGroup> beneath element <Target> is unrecognized.
【问题讨论】:
-
你有没有试过看看它是否有效?输出是什么?
-
@DanCsharpster 刚试了一下,出现错误:
error MSB4067: The element <PropertyGroup> beneath element <Target> is unrecognized. -
与这种愚蠢的单路径Linux 的东西相比,您应该更轻松地引用编译器nuget 包,它将在您的项目中克隆Roslyn 编译器并使用它。
-
这里的答案可能对你有用。 social.msdn.microsoft.com/Forums/vstudio/en-US/…
-
@Blindy 很有趣,你能详细说明一下吗?