Visual Studio 2017 MSBuild 问题

Visual Studio 2017 MSBuild issue

我正在尝试从另一个项目发布一个 Visual stuido 项目,为此我创建了一个 bat 文件,其中 运行 是我的 MSBuild 文件。如果您 运行 在 Visual Studio 之外使用它,它可以正常工作,但是当我尝试将它添加到 Visual Studio 的预构建脚本时,它不会发布。我收到此警告 -

 C:\Program Files (x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3247: Found confl
icts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select
it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the a
pplication configuration file 

我的 MSBuild 文件:

<Target Name="BeforeBuild">
<MSBuild
        Projects="E:\Development\alyz\myAPI\View.API.sln"
        Targets="View_API_Search"
        Properties="DeployOnBuild=true;Configuration=Release;PublishProfile=InstallerPublish;WebPublishMethod=FileSystem;PublishURL=E:\Temp\installertemp\SearchAPI" /> 
</Target>

Visual Studio 说我的项目已经正确构建,但我无法弄清楚为什么它没有发布,有什么想法吗?

Visual Studio is saying that my project has built correctly but i can't work out why it's not publishing, any ideas?

您可以使用其他解决方案来解决此问题。以下是我的发布目标,您可以查看:

  <Target Name="BeforeBuild">
    <Exec Command="&quot;<YourMSBuild.exePath>\msbuild.exe&quot; &quot;<YourSolutionPath>\View.API.sln&quot; /p:DeployOnBuild=true /p:PublishProfile=InstallerPublish.pubxml /p:Configuration=Release /p:PublishURL=E:\Temp\installertemp\SearchAPI"></Exec>
  </Target>

使用此目标,project/solution 将在您构建项目时构建和发布。

希望对您有所帮助。