MSBUILD : error MSB1009: Project file does not exist

Bashir Obaid 6 Reputation points
2021-10-01T19:41:59.65+00:00

I am trying to build an asp.net using Jenkins and Nuget tool and but I got the error" MSBUILD : error MSB1009: Project file does not exist"

C:\ProgramData\chocolatey\bin\nuget.exe restore MyProject.sln -msbuildpath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"

/p:Configuration=Release /p:RunOctoPack=true /p:OctoPackEnforceAddingFiles=true /p:OctoPackPackageVersion=1.0.$BUILD_NUMBER

C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins.jenkins\workspace\bash>C:\ProgramData\chocolatey\bin\nuget.exe restore MyProject.sln -msbuildpath "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"
Using Msbuild from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin'.
All packages listed in packages.config are already installed.

C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins.jenkins\workspace\bash>exit 0
Path To MSBuild.exe: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\msbuild.exe
Executing the command cmd.exe /C " chcp 1252 & "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release /p:RunOctoPack=true /p:OctoPackEnforceAddingFiles=true /p:OctoPackPackageVersion=2.0.46 MyProject.sln " && exit %%ERRORLEVEL%% from C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins.jenkins\workspace\bash
[bash] $ cmd.exe /C " chcp 1252 & "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release /p:RunOctoPack=true /p:OctoPackEnforceAddingFiles=true /p:OctoPackPackageVersion=2.0.46 MyProject.sln " && exit %%ERRORLEVEL%%
Active code page: 1252
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1009: Project file does not exist.
Switch: MyProject.sln
Build step 'Build a Visual Studio project or solution using MSBuild' marked build as failure
Finished: FAILURE

Any help? Thank you

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,879 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Michael Taylor 47,716 Reputation points
    2021-10-01T21:39:57.65+00:00

    You're using a relative path to the solution file (MyProject.sln) but it is being run from a command prompt which is running from%SYSTEMROOT% hence it cannot find the file. Specify the full path to the solution file or, alternatively, ensure the working directory is set to the path to the solution file before running the build command.

    1 person found this answer helpful.

  2. Mohammad Aftab 0 Reputation points
    2022-05-16T17:25:02.423+00:00

    Hi, i configured the path in pipeline correctly but still i have this error :

    *MSBUILD : error MSB1009: Project file does not exist. Switch: *
    C:\Users\maftab\source\repos\BizTalkServerOrchestration\BizTalkServerOrchestration.sln
    ##[error]Process 'msbuild.exe' exited with code '1'.

    Full error : below

    "C:\newagent_work_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [17.0,18.0) -latest -format json

    "C:\newagent_work_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [17.0,18.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json

    "C:\newagent_work_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json

    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "C:\Users\maftab\source\repos\BizTalkServerOrchestration\BizTalkServerOrchestration.sln" /nologo /nr:false /dl:CentralLogger,"C:\newagent_work_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=bc9c26da-3043-4258-aa51-40deb3467929|SolutionDir=C:\Users\maftab\source\repos\BizTalkServerOrchestration|enableOrphanedProjectsLogs=true"*ForwardingLogger,"C:\newagent_work_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.199.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:VisualStudioVersion="16.0" /p:_MSDeployUserAgent="VSTS_f82be4ec-4c29-4226-9dfa-8eb0a30e25b0_build_8_0"

    MSBUILD : error MSB1009: Project file does not exist.

    Switch: C:\Users\maftab\source\repos\BizTalkServerOrchestration\BizTalkServerOrchestration.sln

    [error]Process 'msbuild.exe' exited with code '1'.

    0 comments No comments