-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Bug]: Internal MSBuild Error: Targets cannot be reset once set. #9838
Comments
@GangWang01 let's see if we can repro this |
I couldn't reproduce with nuget package Microsoft.Build 17.9.5. @xtmq Can you share the following information for helping to reproduce? Thank you!
|
I can not reproduce it also. It fails on our CI/CD server like once per week or once per 200-300 builds. The solution - 300 class library projects with single file inside. |
Hi! Sorry for the delay, here is the project where this error occurs. As it's stated above, problem occurs quite rarely, but and is visible from our CI only. Please let us know which additional information we can provide. |
Now we observe the same exception, but from
|
@xtmq do you use to Microsoft.Build.Locator to register the instance of .NET SDK.? From the code snippet in the issue description, I couldn't know about it. And what's the version of MSBuild packages as well as .NET SDK? |
I use msbuild from this SDK: |
@xtmq To get MSBuild work, besides MSBuild assemblies it also requires importing necessary props and targets files from SDK. Can you provide a minimal project that includes how it references MSBuild assemblies and imports props and targets files from SDK? So that we can try to reproduce the issue. |
Hi @GangWang01 ! Thanks for your help with the investigation. It's actually the same project we use in tests which I have pasted above in the issue. There is nothing specific except of having 300 synthetic library projects all of which target net8.0. And problem appears while loading some of them once in a while. Loading is done as per that code snippet above. |
@rwx788 Thanks for quick response!
Here the project is the one that has the code snippet above loading the test projects. It helps to understand if necessary props and targets files from SDK are imported correctly. |
This issue is marked as stale because feedback has been requested for 30 days with no response. Please respond within 14 days or this issue will be closed due to inactivity. |
This issue was closed due to inactivity. If you can still reproduce this bug, please comment with the requested information, detailed steps to reproduce the problem, or any other notes that might help in the investigation. |
Issue Description
Hello MSBuild Team! As you may know Rider uses MSBuild API to load and build projects. Some time ago we faced a new issue with project loading:
We get this exception from time to time (but very seldom) when Rider has to load lots of tiny projects on solution opening. Our code looks like this simplified example:
This starts to happening on Linux in this SDK:
dotnet-sdk-8.0.100-linux-x64-c4c95f56
Looks like something was changed inside
ProjectInstance
creating and not it is not thread-safe anymore?Steps to Reproduce
We don't have exact steps now. But it is not obvious what was broken in the last SDK we can try to make a repro.
Expected Behavior
no exception
Actual Behavior
exception
Analysis
No response
Versions & Configurations
dotnet-sdk-8.0.100-linux-x64-c4c95f56
The text was updated successfully, but these errors were encountered: