开发者

MSBUILD : error MSB1008: Only one project can be specified

开发者 https://www.devze.com 2023-01-17 03:11 出处:网络
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 /

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 p开发者_StackOverflow中文版roject is being specified.

Is it stored in a project file somewhere?


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

/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.

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


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

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


SOLUTION
Remove the Quotes around the /p:PublishDir setting

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.


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 Education as a switch, try to remove /p:ProductName="Total Education TEST" to see if it works.


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


Try to remove the trailing backslash or slash at the end of you publish path and install 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.

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

Hope it helps!


Yet another cause and solution to this: Check that you didn't put a space in the wrong place, i.e. in parameters; mine was dotnet -c Release - o /home/some/path (note the space between - and o), I kept looking at the path itself, which was correct and threw me off. Hope that helps! (this was in Bash though it should also apply to Windows)


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

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

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(?!)

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


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

/p:password='my secret' bad

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

/p:password="my secret" good

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


For me I had forgot to add closing quote

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

to

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


If you are using Azure DevOps MSBuild task the error may be caused by doubled configuration flag. Please make sure you put $(BuildConfiguration) in specified box instead of MSBuild Arguments one:

MSBUILD : error MSB1008: Only one project can be specified


This worked for me in TFS MSBuild Argument. Note the number of slashes.

/p:DefaultPackageOutputDir="\\Rdevnet\Visual Studio Projects\Insurance\"


If you use default workspace in Jenkins, this might occur. Use custom workspace location without any spaces.

MSBUILD : error MSB1008: Only one project can be specified


For future readers.

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

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"


If you are using Any CPU you may need to put it in single quotes.

Certainly when running in a Dockerfile, I had to use single quotes:

# Fails. Gives: MSBUILD : error MSB1008: Only one project can be specified.
RUN msbuild ConsoleAppFw451.sln /p:Configuration=Debug /p:Platform="Any CPU" 

# Passes. Gives: Successfully built 40163c3e0121
RUN msbuild ConsoleAppFw451.sln /p:Configuration=Debug /p:Platform='Any CPU' 


For me adding the path to the solution file in double quotes solved the issue. One of the folders in the path had a blank space in the name and this caused it to consider 2 solution files instead of one. I executed in the following was and it worked.

MSBuild.exe "C:\Folder Name With Space\Project\project.sln"


In my case, it was the switches. I resolved it by using -p instead of /p.


Just in case someone has the same issue as me, I was missing "/" before one of the "/p" arguments. Not very clear from the description. I hope this helps someone.


I did use solution given in https://www.codingdefined.com/2014/10/solved-msbuild-error-msb1008-only-one.html and that solves the issue. All we need to do is check spaces and ''(check backslashes) in the command


I ran into this issue with a very simple command, which didn't include any quote, any space, any slash, anything strange at all.

I was using MINGW64 shell.

The same exact command from PowerShell worked instead.


In my case:

dotnet build -c Release --no-restore -p:Version=${VERSION} -p:Description=${DESCRIPTION}

I had this error:

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

But I changed it:

-p:Description=${DESCRIPTION}

to

-p:Description="${DESCRIPTION}"

And works.


With .NET 6 CLI, I face the "MSBUILD : error MSB1008: Only one project can be specified." when running the test command with -d

Not Work

 dotnet test Abc.Tests.csproj -d "verbose_log.txt"

Work

 dotnet test Abc.Tests.csproj -d="verbose_log.txt"
 dotnet test Abc.Tests.csproj -d:"verbose_log.txt"
 dotnet test Abc.Tests.csproj --diag "verbose_log.txt"
0

精彩评论

暂无评论...
验证码 换一张
取 消