【问题标题】:Is it possible to run AfterBuild target from csproj.user file?是否可以从 csproj.user 文件运行 AfterBuild 目标?
【发布时间】:2021-02-03 11:51:43
【问题描述】:

我想在 .csproj.user 文件中扩展我的本地构建过程,该文件不在我们的 git 存储库中跟踪。以前我使用PostBuildEvent,但突然发现它不适用于变量:https://github.com/dotnet/sdk/issues/677

适用于 .csproj.csproj.user,但不能有变量:

<PostBuildEvent>xcopy "C:\workspace\project\bin\Debug\my.dll" "C:\Program\bin" /y</PostBuildEvent>

只有放在.csproj 的末尾才有效,但不能放在.csproj.user 中:

<Target Name="AfterBuild">
    <Copy SourceFiles="$(ProjectDir)\$(OutputPath)\my.dll" DestinationFolder="C:\Program\bin" />
</Target>

我还尝试使用简单的&lt;Message&gt; 而非&lt;Copy&gt; 对其进行调试,结果相同。

有没有办法让它在我的.csproj.user 中工作?

【问题讨论】:

    标签: msbuild csproj msbuild-target csproj-user


    【解决方案1】:

    我偶然发现了同样的问题,经过一些实验,解决方案很简单:

    <Target Name="UseAName" AfterTargets="Build">
        <Copy SourceFiles="$(ProjectDir)\$(OutputPath)\my.dll" DestinationFolder="C:\Program\bin" />
    </Target>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-21
      • 1970-01-01
      • 2020-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多