Skip to content

Commit

Permalink
Require individual languages opt-in to Hot Reload
Browse files Browse the repository at this point in the history
* Move capability to C# and VB project imports
* Add a feature switch to opt out of hot reload capability

Fixes #19608
  • Loading branch information
pranavkm committed Aug 11, 2021
1 parent f3c72f1 commit 4e5d90e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ Copyright (c) .NET Foundation. All rights reserved.
<PropertyGroup>
<DefineConstants>$(DefineConstants);$(VersionlessImplicitFrameworkDefine);$(ImplicitFrameworkDefine);$(BackwardsCompatFrameworkDefine)</DefineConstants>
</PropertyGroup>

<!-- Enable hot reload in 6.0 and newer C# projects -->
<ItemGroup Condition="'$(SupportsHotReload)' != 'false' AND '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))">
<ProjectCapability Include="SupportsHotReload" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Copyright (c) .NET Foundation. All rights reserved.
<FinalDefineConstants Condition="'$(MyType)' == ''">$(FinalDefineConstants),_MyType=&quot;Empty&quot;</FinalDefineConstants>
</PropertyGroup>

<!-- Enable hot reload in 6.0 and newer VB projects -->
<ItemGroup Condition="'$(SupportsHotReload)' != 'false' AND '$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))">
<ProjectCapability Include="SupportsHotReload" />
</ItemGroup>

<!--
NOTE: We must hook directly to CoreCompile for compatibility with two phase XAML
build. We also must not pull in a dependency on ResolveAssemblyReferences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,14 +1066,14 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- Don't generate a NETSDK1151 error if a non self-contained Exe references a Blazor wasm Exe -->
<ShouldBeValidatedAsExecutableReference>false</ShouldBeValidatedAsExecutableReference>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' == 'true' And '$(ValidateExecutableReferencesMatchSelfContained)' == ''">
<!-- Don't generate an error if a test project references a self-contained Exe. Test projects
use an OutputType of Exe but will usually call APIs in a referenced Exe rather than try
to run it. -->
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<!-- Don't generate an error if an Exe project references a test project. -->
<ShouldBeValidatedAsExecutableReference>false</ShouldBeValidatedAsExecutableReference>
Expand Down Expand Up @@ -1102,13 +1102,13 @@ Copyright (c) .NET Foundation. All rights reserved.

<Target Name="ValidateCommandLineProperties"
AfterTargets="_CheckForInvalidConfigurationAndPlatform" >

<NETSdkWarning Condition="'$(_CommandLineDefinedSelfContained)' != 'true' and
'$(_CommandLineDefinedRuntimeIdentifier)' == 'true' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))"
ResourceName="SelfContainedOptionShouldBeUsedWithRuntime" />

</Target>

<!--
Expand All @@ -1126,11 +1126,6 @@ Copyright (c) .NET Foundation. All rights reserved.
<ProjectCapability Remove="ReferenceManagerAssemblies" />
</ItemGroup>

<!-- Enable hot reload in 6.0 and newer apps by default -->
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))">
<ProjectCapability Include="SupportsHotReload" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.DisableStandardFrameworkResolution.targets" Condition="'$(DisableStandardFrameworkResolution)' == 'true'" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.DesignerSupport.targets" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.NET.GenerateAssemblyInfo.targets" Condition="'$(UsingNETSdkDefaults)' == 'true'"/>
Expand Down

0 comments on commit 4e5d90e

Please sign in to comment.