簡體   English   中英

msbuild不會在發布配置中進行構建

[英]msbuild won't build in release configuration

使用msbuild 14.0並從命令中調用它:

C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe C:\\Project\\MySolution.sln /t:Build /p:Configuration=Release /p:Platform='Any CPU'

MySolution是Visual Studio C#解決方案,由幾個項目組成: Project1Project2 ,...

輸出:

Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 2018-06-08 10:48:08 AM.
Project "C:\Project\MySolution.sln" on node 1 (Build /p:Configuration=Release /p:Platform='Any CPU
' target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
ValidateProjects:
  The project "Project3" is not selected for building in solution configuration "Debug|Any CPU".
C:\Project\MySolution.sln.metaproj : error MSB4057: The target "Build /p:Configuration=Release /p:
Platform='Any CPU'" does not exist in the project. [C:\Project\MySolution.sln]
Done Building Project "C:\Project\MySolution.sln" (Build /p:Configuration=Release /p:Platform='Any
 CPU' target(s)) -- FAILED.


Build FAILED.
  • 為什么msbuild無法在發布配置中構建解決方案? 它始終默認為調試 ?? 從Visual Studio調用解決方案時,該解決方案已正確配置,並且使用該配置進行構建不會有任何問題。

  • msbuild始終選擇Project3,並聲稱未選擇在解決方案配置“ Debug | Any CPU”中進行構建,這是不正確的。 此解決方案中的所有項目也可以在調試配置中構建。 但這不是我要在這里做的。

解決方案配置的屏幕截圖:

解決方案配置的屏幕截圖

列表底部的兩個未選中項目是單元測試。


附加問題:

  • 如何將/verbosity開關集成到build命令中?

我使用msbuild 15.0代替了msbuild 14.0(無論如何我都以4.6.1為目標框架),錯誤消失了。

您能否在命令中添加此附加屬性並進行檢查。

/p:TargetFramework=<version>

在選擇調試/發布的列表框中,單擊“配置管理器”,然后檢查解決方案發布配置是否將所有項目都設置為“發布”->“ AnyCPU”。 在此處輸入圖片說明

希望有幫助,軍團


第二題答案:

/fileLogger1 /fileLoggerParameters:LogFile=MyLog.log;Append; Verbosity=diagnostic;Encoding=UTF-8

要么

/verbosity:diagnostic

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM