Visual Studio 2017 - PreBuild事件命令行(构建另一个项目)

时间:2017-11-15 09:28:32

标签: visual-studio-2017

我有一个包含多个项目的解决方案。

当我构建项目'Foo'时,我需要在Foo之前​​构建项目'SimplePluginFramework'。

它还需要在Release模式下构建'SimplePluginFramework',即使Foo是在调试模式下构建的。

我尝试将此添加到Foo的预构建事件命令行,但它存在代码9009并且Bar不构建...

 $(MSBuildBinPath)\MSBuild.exe "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" /t:build /p:Configuration=Release 

如何构建一个项目在构建之前触发另一个项目的构建?

我已经尝试添加对该项目的引用,但它仍然没有构建它。

错误:

    1>Target "PreBuildEvent" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "L:\SL1-(SentiLAN)-SentiLAN v1 - Current System\SentilanCore\SentiLAN Agent\SentilanV1\AgentServiceTpl\SentilanService\SentilanService.csproj" (target "CoreBuild" depends on it):
1>Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "Exec"
1>  "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" /t:build /p:Configuration=release
1>  Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
1>  Copyright (C) Microsoft Corporation. All rights reserved.
1>  
1>  Build started 15/11/2017 09:47:32.
1>  Project "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" on node 1 (build target(s)).
1>  GenerateTargetFrameworkMonikerAttribute:
1>  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>  CoreCompile:
1>  Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
1>  _CopyAppConfigFile:
1>  Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
1>  CopyFilesToOutputDirectory:
1>    SimplePluginFramework -> L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\lib\net35\SimplePluginFramework.dll
1>  Done Building Project "L:\SL1 - Current System\Core\SL Agent\SLV1\Agent\SimplePluginFramework\SimplePluginFramework.csproj" (build target(s)).
1>  
1>  Build succeeded.
1>      0 Warning(s)
1>      0 Error(s)
1>  
1>  Time Elapsed 00:00:00.22

项目依赖项:

enter image description here

1 个答案:

答案 0 :(得分:2)

使用项目|项目依赖关系定义Foo取决于SimplePluginFramework。

使用解决方案配置(右键单击解决方案并选择属性)在解决方案级别定义调试配置使用Foo的调试版本,但使用SimplePluginFramework的发布版本。

相关问题