【问题标题】:Unable to specify project of solution for MSBuild无法为 MSBuild 指定解决方案项目
【发布时间】:2021-03-03 12:52:25
【问题描述】:

我有以下解决方案:

MySolution\
   MySolution.sln
   MyCSProject\
      MyCSProject.csproj
   MyCPPProject\
      VC11\
         projfile.vcxproj
      VC8
         projfile.vcproj
   MyInstallationProject
      MyInstallationPackage.vdproj

在 Visual Studio 中,我将 MyCSProject 设置为主项目。但是对于自动构建,我需要构建 MyInstallationProject 与依赖项。 MyInstallationProject 取决于 MyCSProjectMyCSProject 取决于 MyCPPProject。如果我从 Visual Studio 构建,它可以工作。

但对于 MSBuild,我无法编写正确的命令。以下都不起作用:

"...\MSBuild.exe" MySolution.sln /t:MySolution\MyInstallationProject /p:Configuration="Release" /p:Platform="x64"

"...\MSBuild.exe" MySolution.sln /t:MySolution\MyInstallationProject.vdproj /p:Configuration="Release" /p:Platform="x64"

"...\MSBuild.exe" MySolution.sln /t:MyInstallationProject /p:Configuration="Release" /p:Platform="x64"

"...\MSBuild.exe" MyInstallationProject\MyInstallationProject.vdproj /p:Configuration="Release" /p:Platform="x64"

等等,各种报错,主要是“项目中不存在目标***”

如何知道与项目相关的正确命令和/或目标名称?

【问题讨论】:

  • /t:MyInstallationProject 只要名称与.sln 文件中列出的项目名称匹配(可能与.vdproj 名称相同,也可能不同),这应该可以工作。尝试在msbuild 命令行中添加/verbosity:diag,也许它会提供更多线索。

标签: visual-studio command-line msbuild


【解决方案1】:

事实上,第三个和第四个 msbuild 命令行之一应该在你身边工作。还有a document about it

事实上,MSBuild 无法构建vdproj 文件。它来自 VS 安装程序项目扩展,构建工具是独立于扩展而不是 MSBuild 的工具。您可以轻松打开vdproj文件,发现它不是xml样式。

MSBuild 只能构建 xml sytle proj 文件。

对其进行测试,您可以为 MyCSProject 项目尝试相同的 msbuild 命令行来获得差异。

所以正确的方法是使用 VS IDE 构建或使用devenv build command line,这意味着你必须在本地安装 VS IDE。

试试下面的命令行:

1)打开VS的开发者命令提示符:

2) 运行:

cd xxx\xxx\MySolution
devenv MyInstallationProject\MyInstallationProject.vdproj /build

【讨论】:

  • 嗯...我需要这个才能在 azure 管道的CI 环境中工作....
  • devenv <solutionfilename> /build 什么都不做; devenv <projectdirectory>\<projectfilenam> /build 什么都不做; devenv <solutionfilename> /build /project <projectdirectory>\<projectfilenam> 显示错误窗口 Missing switch argument. Configuration name required for /build switch.
  • @Dims,你必须指定sln全名或vdproj全名,你可以使用devenv xxx\MySolution.sln /builddevenv xxx\MyInstallationProject.vdproj /build
猜你喜欢
  • 1970-01-01
  • 2012-12-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-15
  • 2018-03-08
  • 2016-04-26
相关资源
最近更新 更多