visual-studio MSBUILD:错误 MSB1008:只能指定一个项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3779701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 12:29:03  来源:igfitidea点击:

MSBUILD : error MSB1008: Only one project can be specified

visual-studiovisual-studio-2008msbuild

提问by Gerhard Weiss

Why am I getting the following Build error?

为什么我收到以下构建错误?

C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe C:\Code\EduBenesysNET\EduBenesysNET\EduBenesysNET.vbproj /t:publish /p:Configuration=Release /p:Platform=AnyCPU /v:detailed /p:PublishDir="\BSIIS3\c$\DATA\WEBSITES\benesys.net\benesys.net\TotalEducationTest\"  /p:InstallUrl="https://www.benesys.net/benesys.net/TotalEducationTest/"  /p:ApplicationVersion=1.0.1.198  /p:ProductName="Total Education TEST"   /p:PublisherName="BeneSys, Inc."  /p:UpdateRequired="True"  /p:MinimumRequiredVersion=1.0.1.198
Microsoft (R) Build Engine Version 3.5.30729.1
[Microsoft .NET Framework, Version 2.0.50727.3603]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

MSBUILD : error MSB1008: Only one project can be specified.
Switch: Education

For switch syntax, type "MSBuild /help"

I do not see how a second project is being specified.
Is it stored in a project file somewhere?

我没有看到如何指定第二个项目。
它是否存储在某个项目文件中?

采纳答案by Gerhard Weiss

SOLUTION
Remove the Quotes around the /p:PublishDir setting

解决方案
删除 /p:PublishDir 设置周围的引号

i.e.
Instead of quotes


而不是引号

/p:PublishDir="\BSIIS3\c$\DATA\WEBSITES\benesys.net\benesys.net\TotalEducationTest\"  

Use no quotes

不使用引号

/p:PublishDir=\BSIIS3\c$\DATA\WEBSITES\benesys.net\benesys.net\TotalEducationTest\  

I am sorry I did not post my finding sooner. I actually had to research again to see what needed to be changed. Who would have thought removing quotes would have worked? I discovered this when viewing a coworkers build for another solution and noticed it did not have quotes.

很抱歉我没有早点发布我的发现。我实际上不得不再次研究以查看需要更改的内容。谁会想到删除引号会起作用?我在查看同事为另一个解决方案构建时发现了这一点,并注意到它没有引号。

回答by Matt

It turns out the trailing slash in the PublishDir property is escaping the end quote. Escaping the trailing slash solved my problem.

结果证明 PublishDir 属性中的尾部斜杠正在转义结束引号。转义尾随斜杠解决了我的问题。

/p:PublishDir="\BSIIS3\c$\DATA\WEBSITES\benesys.net\benesys.net\TotalEducationTest\"

This way we can use quotes for paths that have whitespace in properties that MSBuild requires the trailing slash.

通过这种方式,我们可以对 MSBuild 需要尾部斜杠的属性中包含空格的路径使用引号。

I know this is an old post, but I feel like I needed to share this with someone :-)

我知道这是一篇旧帖子,但我觉得我需要与某人分享:-)

回答by friday

On Git Bash I had to specify the parameters with double slashes like:

在 Git Bash 上,我必须用双斜杠指定参数,例如:

MSBuild.exe "Path\to\Solution.sln" //p:Platform="x86" //p:Configuration=Release //p:AppxBundlePlatforms="x86" 

回答by Julien Hoarau

This problem appears when you have a path or a property containing a space and that is not quoted.

当您的路径或属性包含空格且未引用时,就会出现此问题。

All your properties and path have quote around them, it's strange. The error message indicates Educationas a switch, try to remove /p:ProductName="Total Education TEST"to see if it works.

你所有的属性和路径都有引号,这很奇怪。错误信息提示Education为开关,请尝试移除/p:ProductName="Total Education TEST"以查看是否有效。

回答by Zamir

You need to put qoutes around the path and file name.
So use MSBuild "C:\Path Name\File Name.Exe" /[Options]

您需要在路径和文件名周围放置 qoutes。
所以使用 MSBuild "C:\Path Name\File Name.Exe" /[Options]

回答by Cédric Rup

Try to remove the trailing backslash or slash at the end of you publish path and install url

尝试删除发布路径末尾的尾随反斜杠或斜杠并安装 url

/p:PublishDir="\BSIIS3\c$\DATA\WEBSITES\benesys.net\benesys.net\TotalEducationTest"
/p:InstallUrl="https://www.benesys.net/benesys.net/TotalEducationTest"

You must have hit a special sequence of characters with the \" and (or) /", but I don't know enough in cmd.exe to figure out.

您必须使用 \" 和(或)/" 命中一个特殊的字符序列,但我对 cmd.exe 的了解不够,无法弄清楚。

I personnaly always use Powershell : it's way more friendly and powerful!

我个人总是使用 Powershell:它更友好、更强大!

Hope it helps!

希望能帮助到你!

回答by user3636264

In vs2012 just try to create a Build definition "Test Build" using the default TFS template "DefaultTemplate....xaml" (usually a copy of it)

在 vs2012 中,只需尝试使用默认的 TFS 模板“DefaultTemplate....xaml”(通常是它的副本)创建一个构建定义“测试构建”

It will fail with the usual self-explaining-error: "MSBUILD : error MSB1008: Only one project can be specified.Switch: Activities"

它将失败并出现通常的自我解释错误:“MSBUILD:错误 MSB1008:只能指定一个项目。开关:活动”

Off course somewhere in the default TFS template some "are missing so msbuild will receive as parameter a non escaped directory containing spaces so will result in multiple projects(?!)

当然,默认 TFS 模板中的某处"缺少某些内容,因此 msbuild 将接收包含空格的非转义目录作为参数,因此将导致多个项目(?!)

So NEVER use spaces in you TFS Build Definition names, pretty sad and simple at the same time

所以永远不要在你的 TFS 构建定义名称中使用空格,同时非常悲伤和简单

回答by John K

I was using single quotes around the password parameter when I got the error

当我收到错误时,我在密码参数周围使用了单引号

/p:password='my secret'bad

/p:password='my secret'坏的

and changed it to use double quotes to resolve the issue.

并将其更改为使用双引号来解决问题。

/p:password="my secret"good

/p:password="my secret"好的

Likely the same would apply to any parameter that needs quotes for values that contain a space.

这可能同样适用于需要为包含空格的值提供引号的任何参数。

回答by Reza

For me I had forgot to add closing quote

对我来说,我忘了添加结束语

/p:DeployOnBuild=true;OutDir="$(build.artifactstagingdirectory)

/p:DeployOnBuild=true;OutDir="$(build.artifactstagingdirectory)

to

/p:DeployOnBuild=true;OutDir="$(build.artifactstagingdirectory)"

/p:DeployOnBuild=true;OutDir="$(build.artifactstagingdirectory)"

回答by granadaCoder

For future readers.

对于未来的读者。

I got this error because my specified LOG file had a space in it:

我收到此错误是因为我指定的 LOG 文件中有一个空格:

BEFORE:

前:

/l:FileLogger,Microsoft.Build.Engine;logfile=c:\Folder With Spaces\My_Log.log

AFTER: (which resolved it)

之后:(解决了它)

/l:FileLogger,Microsoft.Build.Engine;logfile="c:\Folder With Spaces\My_Log.log"