Просмотр исходного кода

Add property to allow the SDK to disable shared framework trimming (#1130)

The MicrosoftNETPlatformLibrary property instructs the .NET Core SDK to treat a particular package as the shared framework platform. This affects how the SDK will trim references and publish output, determines how the runtimeconfig files are generated, and may affect how optimizations are preformed by other tools. In some installations of .NET Core, the ASP.NET Core shared framework is not available. This change adds properties to let the SDK determine on which platforms ASP.NET Core is enabled.
Nate McMaster 7 лет назад
Родитель
Сommit
d6f15759fd

+ 17 - 3
src/Microsoft.AspNetCore.All/build/netcoreapp2.1/Microsoft.AspNetCore.All.props

@@ -1,5 +1,19 @@
 <Project>
-  <PropertyGroup>
-    <MicrosoftNETPlatformLibrary>Microsoft.AspNetCore.All</MicrosoftNETPlatformLibrary>
+  <!--
+    The _AspNetCoreAllSharedFxIsEnabled property is meant for internal use only. When set to 'false',
+    the default value of MicrosoftNETPlatformLibrary will be Microsoft.NETCore.App. It was added to support
+    a better SDK exprience on platforms where the ASP.NET Core shared framework is not avaiable.
+    In these cases, ASP.NET Core can still be as if it were just a set of NuGet packages.
+  -->
+  <PropertyGroup Condition=" '$(_AspNetCoreAllSharedFxIsEnabled)' == '' ">
+    <!--
+      Disable the base runtime, Microsoft.AspNetCore.App, when this package is imported
+    -->
+    <_AspNetCoreAppSharedFxIsEnabled>false</_AspNetCoreAppSharedFxIsEnabled>
+
+    <!--
+      NB: this is _AspNetCore*All*SharedFxIsEnabled, not _AspNetCore*App*SharedFxIsEnabled
+    -->
+    <_AspNetCoreAllSharedFxIsEnabled>true</_AspNetCoreAllSharedFxIsEnabled>
   </PropertyGroup>
-</Project>
+</Project>

+ 11 - 0
src/Microsoft.AspNetCore.All/build/netcoreapp2.1/Microsoft.AspNetCore.All.targets

@@ -1,4 +1,15 @@
 <Project>
+  <!--
+    This property instructs the .NET Core SDK to treat this package as the shared framework platform.
+    This affects how the SDK will trim references and publish output, determines how the runtimeconfig
+    files are generated, and may affect how optimizations are preformed by other tools.
+
+    NB: this is _AspNetCore*All*SharedFxIsEnabled, not _AspNetCore*App*SharedFxIsEnabled
+  -->
+  <PropertyGroup Condition=" '$(_AspNetCoreAllSharedFxIsEnabled)' == 'true' ">
+    <MicrosoftNETPlatformLibrary>Microsoft.AspNetCore.All</MicrosoftNETPlatformLibrary>
+  </PropertyGroup>
+
   <Target Name="EnsureTFMCompatibility" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
     <Error
       Text="This version of Microsoft.AspNetCore.All is only compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1 or choose a version of Microsoft.AspNetCore.All compatible with $(TargetFramework)."

+ 11 - 3
src/Microsoft.AspNetCore.App/build/netcoreapp2.1/Microsoft.AspNetCore.App.props

@@ -1,6 +1,14 @@
 <Project>
+  <!--
+    The _AspNetCoreAppSharedFxIsEnabled property is meant for internal use only. When set to 'false',
+    the default value of MicrosoftNETPlatformLibrary will be used. It was added to support
+    a better SDK exprience on platforms where the ASP.NET Core shared framework is not avaiable.
+    In these cases, ASP.NET Core can still be as if it were just a set of NuGet packages.
+
+    NB: this is _AspNetCore*App*SharedFxIsEnabled, not _AspNetCore*All*SharedFxIsEnabled
+  -->
   <PropertyGroup>
-    <MicrosoftNETPlatformLibrary>Microsoft.AspNetCore.App</MicrosoftNETPlatformLibrary>
+    <_AspNetCoreAppSharedFxIsEnabled Condition=" '$(_AspNetCoreAppSharedFxIsEnabled)' == '' ">true</_AspNetCoreAppSharedFxIsEnabled>
   </PropertyGroup>
 
   <!--
@@ -9,5 +17,5 @@
   <ItemGroup>
     <ProjectCapability Include="AspNetInProcessHosting" />
   </ItemGroup>
-  
-</Project>
+
+</Project>

+ 11 - 0
src/Microsoft.AspNetCore.App/build/netcoreapp2.1/Microsoft.AspNetCore.App.targets

@@ -1,4 +1,15 @@
 <Project>
+  <!--
+    This property instructs the .NET Core SDK to treat this package as the shared framework platform.
+    This affects how the SDK will trim references and publish output, determines how the runtimeconfig
+    files are generated, and may affect how optimizations are preformed by other tools.
+
+    NB: this is _AspNetCore*App*SharedFxIsEnabled, not _AspNetCore*All*SharedFxIsEnabled
+  -->
+  <PropertyGroup Condition=" '$(_AspNetCoreAppSharedFxIsEnabled)' == 'true' ">
+    <MicrosoftNETPlatformLibrary>Microsoft.AspNetCore.App</MicrosoftNETPlatformLibrary>
+  </PropertyGroup>
+
   <Target Name="EnsureTFMCompatibility" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
     <Error
       Text="This version of Microsoft.AspNetCore.App is only compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1 or choose a version of Microsoft.AspNetCore.App compatible with $(TargetFramework)."