Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Debugging MSBuild - setup difficulties#10683

Unanswered
eturgeon123 asked this question inGeneral
Sep 22, 2024· 3 comments· 20 replies
Discussion options

I'm having difficulties setuping my environment in order to launch a simple msbuild run in the debugger.
My understanging is that I have to set some environment variables in order to make it work since the msbuild.exe is not located in his usual location, among other things.

Here's where I'm at right now (the last exception I got), and below I pasted my launch configuration :

C:\Program Files\dotnet\sdk\9.0.100-rc.1.24452.12\sdks\Microsoft.NET.Sdk\Sdk\Sdk.props(49,11):
error MSB4226: The imp
orted project "C:\Users\admin\Documents....\msbuild-main\artifacts\bin\MSBuild\Debug\net472\Current\Microsoft.Commo
n.props" was not found. Also, tried to find "Current\Microsoft.Common.props" in the fallback search path(s) for $(MSBui
ldExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Users\admin\Documents...\msbuild-main\artifacts\bin\MSBuild\Debug\net472\MSBuild.exe.Config".

{
"profiles": {
"MSBuild": {
"commandName": "Project",
"commandLineArgs": ""C:\..........sln"",
"environmentVariables": {
"MSBuildSDKsPath": "C:\Program Files\dotnet\sdk\9.0.100-rc.1.24452.12\sdks",
"DOTNET_ROOT": "C:\Program Files\dotnet",
"MSBuildExtensionsPath": "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current"

    }}

}
}

setting the MSBuildExtensionsPath does nothing in fact. MSBuildExtensionsPath ends up being the location of the msbuild.exe of my build (msbuild-main\artifacts\bin\MSBuild\Debug\net472). I'm not even sure it is necessary to try to set those variables.

You must be logged in to vote

Replies: 3 comments 20 replies

Comment options

It sounds like you want to debug msbuild.exe. If so, you can refer towalkthroughs.

You must be logged in to vote
0 replies
Comment options

Thank you. Running the build.cmd produced the artifact folder with the msbuild in it (artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\MSBuild.exe), however when I launch the debugger with the project msbuild as startup project, I get the following errors :

error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.

This is why yesterday I was trying to set some environment variable to help it find the sdk, but I find it weird that this would not be mentionned in the wiki.
In the debugging section of the wiki, the environment variable MSBUILDDEBUGONSTART is mentionned, so I gave it a shot, but it changed nothing.

I also noticed that when I launch the debugger, the .exe that is launched is not the one in the "Current" folder (artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\MSBuild.exe). Which would explain the error I had in the first place, but I don't know how to make sense of it.

You must be logged in to vote
4 replies
@GangWang01
Comment options

Besides MSBuild binaries, to get msbuild.exe work also needs additional dependencies (Roslyn compilers, NuGet, etc.) as the beginning of the walkthrough introduces the "bootstrap" directory. The MSBuild solution at the repository root couldn't work by itself.

And the wiki introduces debugging MSBuild by attaching the debugger through setting the environment variableMSBUILDDEBUGONSTART. After running build.cmd, you need to open the MSBuild solution, then from a command prompt set the environment variable and build a project/solution usingartifacts\bin\bootstrap\net472\MSBuild\Current\Bin\MSBuild.exe. A pop-up window will appear to let you choose the debugger. The opened MSBuild solution is the right one.

@eturgeon123
Comment options

Thank you, I had not understood that I couldn't just launch the debugger in VS pressing F5, targeting the msbuild project. I needed to run the executable in command line and then attach the debugger. You made that clear to me, thank you. I have made some progress, I can attach VS now.

However, I'm unable to successfully build any solution. I tried different solution, and this is the error I get with a very simple one :

& ".\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\MSBuild.exe" "C:.........sln"

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Tasks.Dataflow, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
or one of its dependencies. The system cannot find the file specified.
at Microsoft.Build.Execution.BuildManager.Dispose(Boolean disposing)
at Microsoft.Build.Execution.BuildManager.Dispose() in C:\TFS\P\eturgeon123\MSBuild\src\Build\BackEnd\BuildManager\BuildManager.cs:line 1178
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary2 globalProperties, Dictionary2 restoreProperties,
ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Boolean needToValidateProject, String schemaFile, Int32 cpuCount, Boolean enableNodeReuse,
TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet1 warningsAsErrors, ISet1 warningsNotAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore,
ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, ProjectIsolationMode isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, Boolean
question, Boolean isBuildCheckEnabled, String[] inputResultsCaches, String outputResultsCache, Boolean saveProjectResult, BuildResult& result, Boolean reportFileAccesses, String
commandLine) in C:\TFS\P\user\MSBuild\src\MSBuild\XMake.cs:line 1694
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine) in C:\TFS\P\user\MSBuild\src\MSBuild\XMake.cs:line 1045
at Microsoft.Build.CommandLine.MSBuildApp.Main() in C:\TFS\P\user\MSBuild\src\MSBuild\XMake.cs:line 276

Of course, this solution does build if I do it from visual studio.

@GangWang01
Comment options

I don't hit this error. What's the Visual Studio version you use? It's probably not compatible with the latest code in main branch of MSBuild. The "bootstrap" directory acquires the additional dependencies from local installed Visual Studio.

@eturgeon123
Comment options

The latest version, 17.11.4.

Comment options

I did not mentionned it, but my goal is to modify msbuild.exe in order to removeall the warning it emits, since its not possible to do that with configs/arguments.

You must be logged in to vote
16 replies
@eturgeon123
Comment options

the -nowarn switch seems to work. So I will have to retry the response file solution

@eturgeon123
Comment options

@KalleOlaviNiemitalo

I tried it in the props file, and it does not work. I still see the MSB3277/CS0162 warnings when I build in Visual studio.
<NoWarn>NU1605;MSB3277;CS0162;CS0219</NoWarn>

@KalleOlaviNiemitalo
Comment options

Do you set a NoWarn property in the project too? If you do, it'll override what's in Directory.Build.props, unless it explicitly appends, e.g.

<PropertyGroup>    <NoWarn>$(NoWarn);CS1591</NoWarn></PropertyGroup>
@eturgeon123
Comment options

I removed it from the csproj, but I still see the warnings.

@eturgeon123
Comment options

Worth mentionning , I just tried the /clp:ErrorsOnly switch, which could sometimes be pleasant. But with it the build time goes from 74 seconds to 155 seconds. Which makes no sense to me .

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
3 participants
@eturgeon123@GangWang01@KalleOlaviNiemitalo

[8]ページ先頭

©2009-2025 Movatter.jp