-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Fix building coreclr SPC inside VS #116925
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
Conversation
- Use the correct hook points for illink targets (CoreCompileDependsOn) - Move target imports into a D.B.targets file as inside the project file is too early to override properties. - Update targetingpacks.targets to not throw error in design time build - Remove unnecessary target from S.P.CoreLib.csproj
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.
Pull Request Overview
This PR fixes building System.Private.CoreLib inside Visual Studio by relocating ILLink and optimization imports, updating hook points for ILLink, adjusting design-time build behavior, and removing an obsolete inline target.
- Move ILLink descriptor and codeOptimization imports into
Directory.Build.targets
- Update hook points to use
CoreCompileDependsOn
and addResolveProjectReferences
- Skip the targeting pack error during design-time builds
- Remove the inlined ILLink target from the project file
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj | Removed inline imports and the CreateRuntimeRootIlLinkDescFile target |
src/coreclr/System.Private.CoreLib/Directory.Build.targets | Added imports for ILLink descriptor and codeOptimization targets |
src/coreclr/System.Private.CoreLib/CreateRuntimeRootILLinkDescriptorFile.targets | Switched to CoreCompileDependsOn , added ResolveProjectReferences dependencies |
eng/targetingpacks.targets | Modified error condition to skip during design-time builds |
Comments suppressed due to low confidence (2)
eng/targetingpacks.targets:127
- Consider adding a test or integration step to verify that design-time builds no longer fail at this error condition.
Condition="!Exists('$(LocalRefPackDir)\data\FrameworkList.xml') and '$(DesignTimeBuild)' != 'true'" />
src/coreclr/System.Private.CoreLib/Directory.Build.targets:3
- The call to GetPathOfFileAbove is missing quotes around the filename literal; it should be GetPathOfFileAbove('Directory.Build.targets', …) to correctly locate the file.
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
src/coreclr/System.Private.CoreLib/CreateRuntimeRootILLinkDescriptorFile.targets
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/CreateRuntimeRootILLinkDescriptorFile.targets
Show resolved
Hide resolved
Tagging subscribers to this area: @hoyosjs |
Does this fix work for Native AOT and Mono CoreLib's as well? |
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.
LGTM otherwise
NativeAOT is difficult because the AsmOffsets.cs file is generated by the native build. Maybe we can utilize a similar technique to the "runtime root descriptor" task to have it generated in the managed build? |
The other CoreLibs dont have this exact issue but they might run into others as Jeremy hinted. |
You have to build the native runtime to be able to run any tests. What's the point of trying to make corelib build when you cannot do anything with the result? |
I was just trying to come up with a solution to the mentioned possible issue (building NAOT CoreLib without having built the repo first). If that's not something we want to do, then that's not something we need to do. |
@@ -1,7 +1,7 @@ | |||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
|
|||
<PropertyGroup> | |||
<CompileDependsOn Condition="'$(DesignTimeBuild)' != 'true'">$(CompileDependsOn);_CreateILLinkRuntimeRootDescriptorFile</CompileDependsOn> | |||
<CoreCompileDependsOn Condition="'$(DesignTimeBuild)' != 'true'">$(CoreCompileDependsOn);_CreateILLinkRuntimeRootDescriptorFile</CoreCompileDependsOn> |
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.
Generally, I thought the guidance was dotnet/sourcelink#392 (comment) to do a BeforeCompile for codegen. Is this coming from any behavior worth commenting or any new documentation?
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.
These targets need to run before CoreCompile runs as Csc reads outputs from the targets. So CoreCompileDependsOn
is the right hook point. We don't use Before or After Targets here so there's no sequencing issue.
For libs devs, the coreclr one matters as its the default P2P dependency and is therefore part of the solution files. Being able to |
Is the idea that once you build it you will throw it against the CI to see whether it actually works? I think it encourages bad engineering habits. |
Agreed, we still rely on local and CI validation. We don't encourage to skip running tests locally when the build succeeds. For the libraries portion of the managed code we are interested in being able to build managed code with the least amount of upfront steps in at least the following scenarios:
|
With these changes I can now finally build coreclr S.P.CoreLib inside VS without any errors from a fresh clone and without any upfront steps.