添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
逆袭的苹果  ·  提交交互式任务·  7 月前    · 
多情的创口贴  ·  如何在 docker-compose ...·  1 年前    · 
憨厚的奔马  ·  django 重写user表 继承 ...·  1 年前    · 

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

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

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.

The error you originally reported wasn't on the nuget restore call but the msbuild call.

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%%

Use the full path the SLN file here.

I should also point out that it appears you're cloning and building your app from %SYSTEMROOT% which is likely because you're running Jenkins as a service. I know nothing about Jenkins but I'm willing to bet that you are not specifying a path when you clone/download your source code and it is defaulting. You should absolutely not being trying to download/modify/build code from %SYSTEMROOT%. This is a protected directory structure for the OS only. Your build process should be cloning/downloading your code to a temporary location such as c:\source or c:\projects or something just like you do on your own system. This has several advantages:

  • Security: only admins (which include services running as SYSTEM) has write access (and in some cases read access) to the folders under here and therefore should never be used to store user files like projects.
  • Reduces the path length. While Windows supports long file paths some tools may still limit to old value so having many root level folders (e.g. C:\windows\system32\...) is taking up space over something simple like c:\projects
  • Putting all your projects into a root folder makes it line up more with how your local builds work
  • Putting all your projects into a root folder makes it easier to see what has been built and get to logs if something goes wrong, it also makes cleanup easier over time
  • While your path is unlikely to be causing you issues right now, at some point I would start pointing figures at the locked down directory when things start to fail for no good reason.

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