Kaynağa Gözat

Make native builds work when launching the IIS repo from VS and speed up local builds (#11805)

Justin Kotalik 6 yıl önce
ebeveyn
işleme
3fd32ac7e1

+ 1 - 1
Directory.Build.props

@@ -151,7 +151,7 @@
     <!-- Projects which reference Microsoft.AspNetCore.Mvc.Testing should import this targets file to ensure dependency .deps.json files are copied into test output. -->
     <MvcTestingTargets>$(MSBuildThisFileDirectory)src\Mvc\Mvc.Testing\src\Microsoft.AspNetCore.Mvc.Testing.targets</MvcTestingTargets>
     <!-- IIS native projects can only be built on Windows for x86 and x64. -->
-    <BuildIisNativeProjects Condition="'$(BuildNative)' == 'true' AND '$(TargetOsName)' == 'win' AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64')">true</BuildIisNativeProjects>
+    <BuildIisNativeProjects Condition="('$(BuildNative)' == 'true' OR '$(BuildingInsideVisualStudio)' == 'true') AND '$(TargetOsName)' == 'win' AND ('$(TargetArchitecture)' == 'x86' OR '$(TargetArchitecture)' == 'x64')">true</BuildIisNativeProjects>
     <!-- This property is shared by several projects to layout the AspNetCore.App targeting pack for installers -->
     <TargetingPackLayoutRoot>$(ArtifactsObjDir)TargetingPack.Layout\$(Configuration)\</TargetingPackLayoutRoot>
     <!-- This property is shared by several projects to layout the AspNetCore.App shared framework for installers -->

+ 1 - 1
src/Servers/IIS/build.cmd

@@ -1,3 +1,3 @@
 @ECHO OFF
 SET RepoRoot=%~dp0..\..\..
-%RepoRoot%\build.cmd -projects %~dp0**\*.csproj %*
+%RepoRoot%\build.cmd -BuildNative -projects %~dp0**\*.csproj %* 

+ 6 - 2
src/Servers/IIS/build/native.targets

@@ -5,11 +5,15 @@
   </PropertyGroup>
 
   <ItemGroup Condition="@(MessageFile->Count()) != 0">
-    <CustomBuild Include="@(MessageFile)">
+    <!-- Checking if the IntDir exists is a local development optimization. Normally, each time the build runs,
+      the aspnetcore_msg.h file is auto generated. The compiler notices that the file has been updated, and recompiles c++ files.
+      These files never update (they define message types, which aren't changed). Therefore, if the IntDir exists, don't recreate
+      the header file. -->
+    <CustomBuild Include="@(MessageFile)" Condition="!Exists('$(IntDir)MSG00001.bin')">
       <FileType>Document</FileType>
       <Command>mc "%(FullPath)" -h $(IntDir) -r $(IntDir)</Command>
       <Message>Compiling Event Messages ...</Message>
-      <Outputs>$(IntDir)\%(Filename).rc;$(IntDir)\%(Filename).h;$(IntDir)\MSG0409.bin</Outputs>
+      <Outputs>$(IntDir)\%(Filename).rc;$(IntDir)\%(Filename).h;$(IntDir)\MSG00001.bin</Outputs>
     </CustomBuild>
 
     <MessageFile Remove="@(MessageFile)" />