Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes misleading error about IIDOptimizer #949

Merged
merged 3 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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