MSBUILD : error MSB1008: Only one project can be specified

Visual StudioVisual Studio-2008Msbuild

Visual Studio Problem Overview


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?

Visual Studio Solutions


Solution 1 - Visual Studio

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 :-)

Solution 2 - Visual Studio

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.

Solution 3 - Visual Studio

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 4 - Visual Studio

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.

Solution 5 - Visual Studio

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

Solution 6 - Visual Studio

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!

Solution 7 - Visual Studio

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

Solution 8 - Visual Studio

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.

Solution 9 - Visual Studio

For me I had forgot to add closing quote

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

to

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

Solution 10 - Visual Studio

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)

Solution 11 - Visual Studio

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: enter image description here

Solution 12 - Visual Studio

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

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

Solution 13 - Visual Studio

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

enter image description here

Solution 14 - Visual Studio

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"

Solution 15 - Visual Studio

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' 

Solution 16 - Visual Studio

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"

Solution 17 - Visual Studio

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.

Solution 18 - Visual Studio

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

Solution 19 - Visual Studio

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.

Solution 20 - Visual Studio

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

Solution 21 - Visual Studio

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.

Solution 22 - Visual Studio

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"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGerhard WeissView Question on Stackoverflow
Solution 1 - Visual StudioMattView Answer on Stackoverflow
Solution 2 - Visual StudioGerhard WeissView Answer on Stackoverflow
Solution 3 - Visual StudiofridayView Answer on Stackoverflow
Solution 4 - Visual StudioJulien HoarauView Answer on Stackoverflow
Solution 5 - Visual StudioZamirView Answer on Stackoverflow
Solution 6 - Visual StudioCédric RupView Answer on Stackoverflow
Solution 7 - Visual Studiouser3636264View Answer on Stackoverflow
Solution 8 - Visual StudioJohn KView Answer on Stackoverflow
Solution 9 - Visual StudioRezaView Answer on Stackoverflow
Solution 10 - Visual StudioChristian RondeauView Answer on Stackoverflow
Solution 11 - Visual StudioJ.WincewiczView Answer on Stackoverflow
Solution 12 - Visual StudioMark MonfortiView Answer on Stackoverflow
Solution 13 - Visual Studiouser8537391View Answer on Stackoverflow
Solution 14 - Visual StudiogranadaCoderView Answer on Stackoverflow
Solution 15 - Visual StudioBadgerspotView Answer on Stackoverflow
Solution 16 - Visual StudioVinit DivekarView Answer on Stackoverflow
Solution 17 - Visual StudioJohnnyView Answer on Stackoverflow
Solution 18 - Visual StudioAnusha M ShettyView Answer on Stackoverflow
Solution 19 - Visual Studioo0'.View Answer on Stackoverflow
Solution 20 - Visual StudioΕ Г И І И ОView Answer on Stackoverflow
Solution 21 - Visual StudioVinicius.BeloniView Answer on Stackoverflow
Solution 22 - Visual StudioHieu LeView Answer on Stackoverflow