GetReferenceAssemblyPaths continues on error in design-time builds#8660
GetReferenceAssemblyPaths continues on error in design-time builds#8660JaynieBai merged 1 commit intodotnet:mainfrom
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.
| TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)" | ||
| BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)" | ||
| > | ||
| ContinueOnError="!$(BuildingProject)"> |
There was a problem hiding this comment.
What's the relationship between the DesignTimeBuild and BuildingProject properties?
There was a problem hiding this comment.
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
DesignTimeBuildproperty. However, non-SDK-style C# and VB projects generally use what we call the "legacy" project system, and it uses theBuildingProjectproperty.
As such, you should make use of both the
DesignTimeBuildandBuildingProjectproperties 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.