Skip to content

Commit

Permalink
Fixes misleading error about IIDOptimizer (#949)
Browse files Browse the repository at this point in the history
  • Loading branch information
j0shuams authored Aug 6, 2021
1 parent fbce33a commit 2c76f77
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
21 changes: 15 additions & 6 deletions nuget/Microsoft.Windows.CsWinRT.IIDOptimizer.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<!-- For the IIDOptimizer to work, it needs to be given all the (reference) assemblies used during compilation
This target consolidates them based on an item group output by the CoreCompile target,
so they may be passed as an option to the IIDOptimizer in the target that invokes the tool -->
<Target Name="CsWinRTGenerateIIDOptimizerResponseFile" AfterTargets="Compile" BeforeTargets="CsWinRTInvokeGuidPatcher"
Condition="'$(CsWinRTIIDOptimizerOptOut)' != 'true'">
<Target Name="CsWinRTGenerateIIDOptimizerResponseFile"
AfterTargets="Compile"
BeforeTargets="CsWinRTInvokeGuidPatcher"
Condition="'$(DesignTimeBuild)' == ''">

<PropertyGroup>
<!-- CsWinRTIIDOptimizerPath: If building in the CsWinRT Repo, then this is set already via Directory.Build.props -->
Expand Down Expand Up @@ -47,20 +49,27 @@ $(GuidPatchTargetAssemblyReferences)
</Target>

<!-- Run the IIDOptimizer on the projection .dll -->
<Target Name="CsWinRTInvokeGuidPatcher" AfterTargets="Compile" BeforeTargets="Link" DependsOnTargets="CsWinRTGenerateIIDOptimizerResponseFile"
Condition="'$(CsWinRTIIDOptimizerOptOut)' != 'true'">
<Target Name="CsWinRTInvokeGuidPatcher"
Condition="'$(DesignTimeBuild)' == ''"
AfterTargets="Compile"
BeforeTargets="Link"
DependsOnTargets="CsWinRTGenerateIIDOptimizerResponseFile">

<Message Text="$(CsWinRTIIDOptimizerCommand)" Importance="$(CsWinRTMessageImportance)" />
<Exec Command="$(CsWinRTIIDOptimizerCommand)" ConsoleToMsBuild="true" IgnoreExitCode="true">

<Exec Command="$(CsWinRTIIDOptimizerCommand)" ConsoleToMsBuild="true" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="CsWinRTGuidPatchOutput" />
<Output TaskParameter="ExitCode" PropertyName="CsWinRTGuidPatchExitCode"/>
</Exec>

</Target>

<!-- When the IIDOptimizer succeeds, replace the input .dll with the patched version -->
<Target Name="CsWinRTReplaceForPatchedRuntime"
Condition="$(CsWinRTGuidPatchExitCode) == 0"
AfterTargets="CsWinRTInvokeGuidPatcher"
BeforeTargets="Link">
BeforeTargets="Link"
DependsOnTargets="CsWinRTInvokeGuidPatcher">

<ItemGroup>
<CsWinRTGuidPatchedFiles Include="$(IIDOptimizerInterimDir)$(AssemblyName).dll;$(IIDOptimizerInterimDir)$(AssemblyName).pdb" />
Expand Down
1 change: 1 addition & 0 deletions nuget/Microsoft.Windows.CsWinRT.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<file src="Microsoft.Windows.CsWinRT.props" target="build"/>
<file src="Microsoft.Windows.CsWinRT.targets" target="build"/>
<file src="Microsoft.Windows.CsWinRT.Authoring.targets" target="build"/>
<file src="Microsoft.Windows.CsWinRT.IIDOptimizer.targets" target="build"/>
<file src="Microsoft.Windows.CsWinRT.Prerelease*.targets" target="build"/>
<file src="Microsoft.Windows.CsWinRT.Authoring.Transitive.targets" target="build"/>
<file src="$interop_winmd$" target="metadata"/>
Expand Down
2 changes: 1 addition & 1 deletion nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ $(CsWinRTIncludeWinRTInterop)

<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Prerelease.targets" Condition="Exists('$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Prerelease.targets')"/>
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.Authoring.targets" Condition="'$(CsWinRTComponent)' == 'true'"/>
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.IIDOptimizer.targets" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.Windows.CsWinRT.IIDOptimizer.targets" Condition="'$(CsWinRTIIDOptimizerOptOut)' != 'true'"/>

</Project>
1 change: 1 addition & 0 deletions nuget/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ C#/WinRT behavior can be customized with these project properties:
| CsWinRTWindowsMetadata | \<path\> \| "local" \| "sdk" \| *$(WindowsSDKVersion) | Specifies the source for Windows metadata |
| CsWinRTGenerateProjection | *true \| false | Indicates whether to generate and compile projection sources (true), or only to compile them (false) |
| CsWinRTGeneratedFilesDir | *"$(IntermediateOutputPath)\Generated Files" | Specifies the location for generated project source files |
| CsWinRTIIDOptimizerOptOut | true \| *false | Determines whether to run the IIDOptimizer on the projection assembly |
\*Default value

**If CsWinRTFilters is not defined, the following effective value is used:
Expand Down

0 comments on commit 2c76f77

Please sign in to comment.