-
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
GetReferenceAssemblyPaths continues on error in design-time builds #8660
Conversation
This fixes an issue where VS design-time builds would fail when reference assemblies could not be found. By allowing the design-time build to continue, the .NET Project System will the nominate a restore which may bring in a package that provides those reference assemblies. Without this addition, the task will fail and the build will end early, such that the restore does not occur and progress is not made. This helps when users do not have targeting packs installed (such as for out-of-support versions of .NET Framework, like v4.5). With this change, a reference assembly package (like `Microsoft.NETFramework.ReferenceAssemblies.net45`) may be downloaded for the user to compile against.
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 good to me!
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 good to go
@@ -1232,7 +1232,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |||
RootPath="$(TargetFrameworkRootPath)" | |||
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)" | |||
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)" | |||
> | |||
ContinueOnError="!$(BuildingProject)"> |
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.
What's the relationship between the DesignTimeBuild
and BuildingProject
properties?
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.
Good point
Different project systems use different properties to distinguish between design-time builds and normal builds. For example, the .NET Project System in this repo builds on top of the Common Project System (CPS) components, and CPS-based project systems set the
DesignTimeBuild
property. However, non-SDK-style C# and VB projects generally use what we call the "legacy" project system, and it uses theBuildingProject
property.
As such, you should make use of both the
DesignTimeBuild
andBuildingProject
properties to determine whether a target is running in a design-time build or a normal build:
<Target Name="AddAdditionalReferences" BeforeTargets="ResolveAssemblyReferences">
<PropertyGroup Condition="'$(DesignTimeBuild)' == 'true' OR '$(BuildingProject)' != 'true'">
<_AvoidExpensiveCalculation>true</_AvoidExpensiveCalculation>
</PropertyGroup>
...
</Target>
Contributes to dotnet/sdk#19506
This fixes an issue where VS design-time builds would fail when reference assemblies could not be found.
By allowing the design-time build to continue, the .NET Project System will the nominate a restore which may bring in a package that provides those reference assemblies.
Without this addition, the task will fail and the build will end early, such that the restore does not occur and progress is not made.
This helps when users do not have targeting packs installed (such as for out-of-support versions of .NET Framework, like v4.5). With this change, a reference assembly package (like
Microsoft.NETFramework.ReferenceAssemblies.net45
) may be downloaded for the user to compile against.Tested locally. See discussion in linked issue for further details.