Skip to content

Commit

Permalink
Bulk fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
j0shuams committed May 21, 2021
1 parent d6f5c04 commit a0f0a5d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 28 deletions.
1 change: 0 additions & 1 deletion nuget/Microsoft.Windows.CsWinRT.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
<file src="$winrt_host_arm64$" target ="runtimes\win-arm64\native"/>
<file src="$winrt_shim$" target ="lib\net5.0\"/>
<file src="$guid_patch$" target ="build\tools\"/>
<file src="$net5_runtime$" target ="build\tools\"/>
</files>
</package>
34 changes: 14 additions & 20 deletions nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -147,40 +147,34 @@ $(CsWinRTFilters)
<Copy SourceFiles="$(CsWinRTGeneratedFilesDir)\$(AssemblyName).winmd" DestinationFolder="$(TargetDir)" UseHardlinksIfPossible="false" SkipUnchangedFiles="true" />
</Target>

<!-- ====================== -->
<!-- Call The GuidPatch tool on the projection .dll -->
<Target Name="CsWinRTInvokeGuidPatcher" Condition="'$(CsWinRTEnableGuidPatch)' == 'true'" AfterTargets="Compile" BeforeTargets="Link">
<!-- We need to invoke GuidPatch.exe. This lives in two different places depending on our environment.
If we are in the CsWinRT repo, we don't have a .nupkg to use to find the exe,
then we need to rely on CsWinRTGuidPatchRepoPath and CsWinRTGuidPatchRuntimePath from src/Directory.Build.props
to get a hold of the files needed
If we are not in the CsWinRT repo, we can use the package paths we know -->

<PropertyGroup Condition="'$(CsWinRTInRepo)' == 'true'">
<!-- We use _DirectoryBuildTargetsBasePath as it is the only way I found to get "c:/.../cswinrt/src" -->
<CsWinRTGuidPatchExePath>$(_DirectoryBuildTargetsBasePath)\$(CsWinRTGuidPatchRepoPath)</CsWinRTGuidPatchExePath>
<CsWinRTGuidPatchRuntimeDll>$(_DirectoryBuildTargetsBasePath)\$(CsWinRTGuidPatchRuntimePath)</CsWinRTGuidPatchRuntimeDll>
</PropertyGroup>

<PropertyGroup Condition="'$(CsWinRTInRepo)' != 'true'">
<CsWinRTGuidPatchExePath>$(CsWinRTPath)build\tools\</CsWinRTGuidPatchExePath>
<CsWinRTGuidPatchRuntimeDll>$(CsWinRTPath)lib\net5.0\</CsWinRTGuidPatchRuntimeDll>
</PropertyGroup>
<Target Name="CsWinRTInvokeGuidPatcher" AfterTargets="Compile" BeforeTargets="Link">

<!-- You can use a Directory.Build.props file to set two properties as the path to the patcher and the winrt.runtime used
- CsWinRTGuidPatchPath
- CsWinRTGuidPatchRuntimeDll
-->
<PropertyGroup>
<CsWinRTGuidPatchExePath Condition="'$(CsWinRTGuidPatchPath)' != ''">$(CsWinRTGuidPatchPath)</CsWinRTGuidPatchExePath>
<CsWinRTGuidPatchRuntimeDll Condition="'$(CsWinRTGuidPatchRuntimePath)' != ''">$(CsWinRTGuidPatchRuntimePath)</CsWinRTGuidPatchRuntimeDll>

<CsWinRTGuidPatchExePath Condition="'$(CsWinRTGuidPatchPath)' == ''">$(CsWinRTPath)build\tools\</CsWinRTGuidPatchExePath>
<CsWinRTGuidPatchRuntimeDll Condition="'$(CsWinRTGuidPatchRuntimePath)' == ''">$(CsWinRTPath)lib\net5.0\</CsWinRTGuidPatchRuntimeDll>

<CsWinRTGuidPatchInput Condition="'$(CsWinRTGuidPatchInput)' == ''">@(BuiltProjectOutputGroupKeyOutput->'%(Identity)')</CsWinRTGuidPatchInput>
</PropertyGroup>


<Exec Command="$(CsWinRTGuidPatchExePath)GuidPatch.exe $(CsWinRTGuidPatchInput) $(CsWinRTGuidPatchRuntimeDll)" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="CsWinRTGuidPatchOutput" />
</Exec>
<!-- Special case when the GuidPatcherOutput doesn't exist? -->

<ItemGroup>
<PatchedFiles Include="$(_DirectoryBuildTargetsBasePath)\GuidPatcherOutput\*.dll" />
</ItemGroup>

<!-- what is the file handed to Link ? Can we pass the output one along? -->
<Copy SourceFiles="@(PatchedFiles)" DestinationFolder="$(TargetDir)" />

</Target>
Expand Down
6 changes: 2 additions & 4 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
</PropertyGroup>

<PropertyGroup>
<CsWinRTInRepo>true</CsWinRTInRepo>
<CsWinRTGuidPatchRepoPath>Perf\GuidPatch\bin\$(Platform)\$(Configuration)\net5.0\</CsWinRTGuidPatchRepoPath>
<!-- Doesn't look like there's a platform in the path ? At least from FileExplorer -->
<CsWinRTGuidPatchRuntimePath>WinRT.Runtime\bin\$(Configuration)\net5.0\</CsWinRTGuidPatchRuntimePath>
<CsWinRTGuidPatchPath>$(MSBuildProjectDirectory)\Perf\GuidPatch\bin\$(Platform)\$(Configuration)\net5.0\</CsWinRTGuidPatchPath>
<CsWinRTGuidPatchRuntimePath>$(MSBuildProjectDirectory)\WinRT.Runtime\bin\$(Configuration)\net5.0\</CsWinRTGuidPatchRuntimePath>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Perf/GuidPatch/GuidPatch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64;x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Perf/GuidPatch/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
if (args.Length != 2)
{
Console.WriteLine($"Expected to be given two arguments. Given {args.Length}");
Expand Down
1 change: 0 additions & 1 deletion src/Projections/Windows/Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0</TargetFrameworks>
<Platforms>x64;x86</Platforms>
<CsWinRTEnableGuidPatch>true</CsWinRTEnableGuidPatch>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit a0f0a5d

Please sign in to comment.