-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Set AnyCPU for ProjectReference to source generators #103819
Conversation
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries |
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.
Before merging we should double check that this doesn't cause double writes or overbuilds. Also cc @ericstj
@@ -56,15 +56,18 @@ | |||
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj" | |||
ReferenceOutputAssembly="false" | |||
OutputItemType="Analyzer" | |||
SetPlatform="Platform=AnyCPU" |
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.
Should we also set it for
runtime/src/libraries/System.Private.CoreLib/gen/System.Private.CoreLib.Generators.csproj
Line 5 in 18bc115
</PropertyGroup> |
/cc @jkoritzinsky |
Any instruction to decide this? Inspecting a binlog from full build? |
The only projects that need this are the ones that set a platform that isn't AnyCPU, right? If so then I think it would be better to tell those projects to not flow the platform to referenced projects. AFAIK that's the property that handles this: https://github.com/dotnet/msbuild/blob/c028e44472dde6a62689a1378d3ee649f903275a/src/Tasks/AssignProjectConfiguration.cs#L120-L125 VS defaults this to true but we already set it to false in runtime: Line 14 in b112eac
Any idea why the platform still gets propagated? And yes, the corelib solution files need to be closure complete (meaning that all project references need to be part of the solution file). |
This answered why it worked fine for me previously. The setting was lifted from libraries in #91873 and became applicable to corelib. It seems that the purpose was to unset
This may also solve the problem in VS. Not sure whether we still need the |
Closing in favor of #104561. Thanks for your contribution anyway. |
The source generators are built with AnyCPU. When opening CoreLib in Visual Studio, it tries to load source generators from platform dependent path since CoreLib is platform dependent, and the generators are not in the solution.
An alternative approach is to include them in corelib.sln.