2

我的 .csproj 在重新生成符号链接的 .csproj 文件中定义了以下构建后事件。这在手动 Visual Studio 构建中可以正常工作,并且符号链接可以毫无问题地重新生成:

 <PostBuildEvent>
  del C:\foo\foo\bin\debug\my.config
  mklink C:\bar\bar\bar\bar\bar\bar\bin\debug\my.config c:\baz\baz\my.config  
</PostBuildEvent>

但是,我正在尝试使用 TFS2015 与使用 MSBuild 的自动构建来设置持续集成,但是在这种情况下,构建失败并显示“命令 mklink C:\bar\bar\bar\bar\bar\bar\bin\debug\ my.config c:\baz\baz\my.config 以代码 1' 退出。

如何通过自动构建重新生成符号链接?

4

1 回答 1

2

我通过以下方式在我的 csproj 文件中将变量 $(BuildingInsideVisualStudio) 设置为 true 来解决此问题:

<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
    <PostBuildEvent>
       del C:\foo\foo\bin\debug\my.config
       mklink C:\bar\bar\bar\bar\bar\bar\bin\debug\my.config c:\baz\baz\my.config  
    </PostBuildEvent>
</PropertyGroup>

我在其他地方将此视为可能的答案,但是我看到的帖子显示语法不正确,并且没有清楚地说明如何在 csproj 构建脚本的上下文中使用该变量。希望这将为某人澄清。

这篇 MSDN 文章很有用: https ://msdn.microsoft.com/en-us/library/ms171468(v=vs.140).aspx

于 2016-06-24T18:26:12.887 回答