-
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
ProjectInstance based build fails with a "Target not found exception" when the instance is mutated #1726
Comments
Mkay, so this behaviour appears to be “by design”. When a build is requested on a ProjectInstance and an out of proc node is used, the out of proc node uses two ProjectInstance objects to recover the state. ProjectInstance1 is the deserialized one. Apparently serializing a ProjectInstance only keeps part of the state: global properties, properties, and items. Everything else (targets, using tasks, etc) is discarded. To recover the missing part of the state, the out of proc node Re-evaluates the entry project form disk into ProjectInstance2. It then merges the two by keeping the properties and items from ProjectInstance1 and everything else from ProjectInstance2. If the properties and items from ProjectInstance1 influence what targets get loaded, and what imports get imported, and if the project files change while the build is running in a way that changes those properties and items, then weird stuff like this failure happens (target not found exception). I don’t quite understand why msbuild is doing this state merging as opposed to also serializing target and task information. So, the fix is to change ProjectInstance to serialize the complete evaluated state, and the out of proc node to reuse it entirely without re-evaluation from disk. This is a big change which would affect all out of proc builds, so probably too risky for RTW. |
The above description does not match my debugging, I was finding that MSBuild was throwing away properties from ProjectInstance1 and hence dotnet/project-system#1554 was occurring. Secondly, it's not viable to retry - as all the builds were failing. |
Potential manifestation: dotnet/project-system#1939 |
What's going on with this? This is still being run into. |
Here's another hit: dotnet/project-system#2076 |
@davkean High chance of inserting the fix on Friday |
Resolves #1726 From issue comments: Previous to this change, when a build is requested on a ProjectInstance and an out of proc node is used, the out of proc node uses two ProjectInstance objects to recover the state. ProjectInstance1 is the deserialized one. Apparently serializing a ProjectInstance only keeps part of the state: global properties, properties, and items. Everything else (targets, using tasks, etc) is discarded. To recover the missing part of the state, the out of proc node Re-evaluates the entry project form disk into ProjectInstance2. It then merges the two by keeping the properties and items from ProjectInstance1 and everything else from ProjectInstance2. If the properties and items from ProjectInstance1 influence what targets get loaded, and what imports get imported, and if the project files change while the build is running in a way that changes those properties and items, then weird stuff like this failure happens (target not found exception). The fix is to change ProjectInstance to serialize the complete evaluated state, and the out of proc node to reuse it entirely without re-evaluation from disk.
The second builds fails with a "target not found exception".
There seem to be two weird things happening here:
The build is failing with a target not found exception, even if the build is started on a ProjectInstance. This is probably because a target is getting conditioned to false. It is my understanding that if you start a build on a project instance, msbuild shouldn’t re-evaluate and just reuse the evaluated state from the project instance.
MSBuild is ignoring the properties that CPS set on a project instance after the project instance info is serialized and sent to the out of proc node.
The text was updated successfully, but these errors were encountered: