-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Implement correct behavior for dotnet build
tracing
#9705
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks plausible to me.
For proper C# tracing, `dotnet build` needs the parameter /p:UseSharedCompilation=false. However, we can't pass that to the other subcommands of `dotnet`, therefore we need to figure out which subcommand of `dotnet` is being invoked.
e23a797
to
e9e5d94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks plausible to me!
invocation = BuildExtractorInvocation(id, compilerPath, | ||
compilerPath, | ||
compilerArguments, nil, { | ||
'/p:UseSharedCompilation=false' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know, if this will cause any problems if '/p:UseSharedCompilation=false' is already set as a part of the command line arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the last specified option wins, and I just tried this and it worked:
✘ criemen@Corneliuss-MacBook-Pro ~/test dotnet new console
The template "Console App" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on /Users/criemen/test/test.csproj...
Determining projects to restore...
Restored /Users/criemen/test/test.csproj (in 120 ms).
Restore succeeded.
criemen@Corneliuss-MacBook-Pro ~/test dotnet clean
Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 07/21/2022 11:00:30.
1>Project "/Users/criemen/test/test.csproj" on node 1 (Clean target(s)).
1>CoreClean:
Creating directory "obj/Debug/net6.0/".
1>Done Building Project "/Users/criemen/test/test.csproj" (Clean target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.79
criemen@Corneliuss-MacBook-Pro ~/test dotnet build /p:UseSharedCompilation=false /p:UseSharedCompilation=false
Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
test -> /Users/criemen/test/bin/Debug/net6.0/test.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:03.00
criemen@Corneliuss-MacBook-Pro ~/test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 😄
Great work!
Thanks a lot for doing all the work that lead to this, @criemen . |
Using Further the manner in which this is done is causing downstream implications to other teams. This is being added as a global property which means it filters down to tasks, targets and sub-builds which do not anticipate seeing this. It's presently causing a number of internal teams errors because it's filtering into commands that do not support it. Can we get some explanation of why this was done? Did you reach out to the compiler team to get a more supported way of working around whatever problem you were hitting? |
@jaredpar CodeQL is intercepting calls to We used to have a .NET profiler based solution, but that’s no longer available. Our old build tracer wasn’t compatible with newer dotnet versions and the new tracer gives us greater flexibility over the command line. You’re raising a valid point regarding performance. We’re aware of this issue, and investigating other approaches that could potentially improve the analysis times. We’ve created an internal issue to improve the documentation around Could you give more detail on failures that are caused by |
Consider attaching a logger to the build instead to gather the CommandLineArgs passed to the Csc task. I would suggest writing and attaching your own MSBuild Logger (adding logger CLI arguments automatically in the same way you've added SharedCompilation arguments). Your logger could listen to |
Curious: how do you all create and use this? Just based on the code here it would seemingly need to be on the same machine as the build. In that case, given you're running an analyisis engine, why are you not just writing a Roslyn based analyzer? There are always risks and issues that come with recreating a As @baronfel mentioned command line arguments are easy to pull from a build. There are several different ways to get command line arguments out of say a binary log that don't change the build performance so dramatically.
This is source of problems I'm seeing right now. |
Thank you for the pointers towards MsBuild loggers. I created an internal issue to explore this approach.
Yes, the build and the analysis (extraction) need to happen on the same machine. I think the current approach was chosen based on its ease of maintenance, simplicity and robustness. We need to support most (all) versions of |
Is the code where you do the analysis available anywhere? Interested in looking how you're creating the |
You can find the main entry point here and the compilation is created here. If you open this folder in VS Code, you can use the below
|
For proper C# tracing,
dotnet build
needs the parameter/p:UseSharedCompilation=false
. However, we can't pass that to the othersubcommands of
dotnet
, therefore we need to figure out which subcommandof
dotnet
is being invoked.