浏览代码

Merge pull request #5010 from AvaloniaUI/microcom-targets

Extract microcom generator stuff into a separate .targets file
Nikita Tsukanov 5 年之前
父节点
当前提交
5857a7c3a3
共有 2 个文件被更改,包括 35 次插入31 次删除
  1. 33 0
      build/MicroCom.targets
  2. 2 31
      src/Avalonia.Native/Avalonia.Native.csproj

+ 33 - 0
build/MicroCom.targets

@@ -0,0 +1,33 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+  <!-- Ensure that code generator is actually built -->
+  <ItemGroup>
+    <ProjectReference Include="..\tools\MicroComGenerator\MicroComGenerator.csproj">
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+      <ExcludeAssets>all</ExcludeAssets>
+      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
+    </ProjectReference>
+  </ItemGroup>
+  
+  <Target Name="GenerateAvaloniaNativeComInterop"
+          BeforeTargets="CoreCompile"
+          DependsOnTargets="ResolveReferences"
+          Inputs="@(AvnComIdl);$(MSBuildThisFileDirectory)/../tools/MicroComGenerator/**/*.cs"
+          Outputs="%(AvnComIdl.OutputFile)">
+    <Message Importance="high" Text="Generating file %(AvnComIdl.OutputFile) from @(AvnComIdl)" />
+    <Exec Command="dotnet ../tools/MicroComGenerator/bin/$(Configuration)/netcoreapp3.1/MicroComGenerator.dll -i @(AvnComIdl) --cs %(AvnComIdl.OutputFile)" LogStandardErrorAsError="true" />
+    <ItemGroup>
+      <!-- Remove and re-add generated file, this is needed for the clean build -->
+      <Compile Remove="%(AvnComIdl.OutputFile)"/>
+      <Compile Include="%(AvnComIdl.OutputFile)"/>
+    </ItemGroup>
+  </Target>
+  <ItemGroup>
+    <UpToDateCheckInput Include="@(AvnComIdl)"/>
+    <UpToDateCheckInput Include="$(MSBuildThisFileDirectory)/../tools/MicroComGenerator/**/*.cs"/>
+  </ItemGroup>
+  <PropertyGroup>
+    <_AvaloniaPatchComInterop>true</_AvaloniaPatchComInterop>
+  </PropertyGroup>
+  <Import Project="$(MSBuildThisFileDirectory)/BuildTargets.targets" />
+</Project>

+ 2 - 31
src/Avalonia.Native/Avalonia.Native.csproj

@@ -20,36 +20,7 @@
   <ItemGroup>
     <ProjectReference Include="..\..\packages\Avalonia\Avalonia.csproj" />
     <ProjectReference Include="..\Avalonia.Dialogs\Avalonia.Dialogs.csproj" />
+    <AvnComIdl Include="avn.idl" OutputFile="Interop.Generated.cs" />
   </ItemGroup>
-  
-  <!-- COM Interop generation -->
-  <ItemGroup>
-    <ProjectReference Include="..\tools\MicroComGenerator\MicroComGenerator.csproj">
-      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
-      <ExcludeAssets>all</ExcludeAssets>
-      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
-    </ProjectReference>
-  </ItemGroup>
-    
-  <Target Name="GenerateAvaloniaNativeComInterop" 
-          BeforeTargets="CoreCompile"
-          DependsOnTargets="ResolveReferences"
-          Inputs="avn.idl;$(MSBuildThisFileDirectory)/../tools/MicroComGenerator/**/*.cs"
-          Outputs="Interop.Generated.cs">
-    <Message Importance="high" Text="Generating Interop.Generated.cs" />
-    <Exec Command="dotnet ../tools/MicroComGenerator/bin/$(Configuration)/netcoreapp3.1/MicroComGenerator.dll -i avn.idl --cs Interop.Generated.cs" LogStandardErrorAsError="true" />
-    <ItemGroup>
-      <!-- Remove and re-add generated file, this is needed for the clean build -->
-      <Compile Remove="Interop.Generated.cs"/>
-      <Compile Include="Interop.Generated.cs"/>
-    </ItemGroup>
-  </Target>
-  <ItemGroup>
-    <UpToDateCheckInput Include="avn.idl"/>
-    <UpToDateCheckInput Include="$(MSBuildThisFileDirectory)/../tools/MicroComGenerator/**/*.cs"/>
-  </ItemGroup>
-  <PropertyGroup>
-    <_AvaloniaPatchComInterop>true</_AvaloniaPatchComInterop>
-  </PropertyGroup>
-  <Import Project="..\..\build\BuildTargets.targets" />
+  <Import Project="../../build/MicroCom.targets" />
 </Project>