Skip to content

Commit

Permalink
Reduce properties required to be set for authoring (#710)
Browse files Browse the repository at this point in the history
* Remove the need for some properties to be set.

* Fix winmd location
  • Loading branch information
manodasanW authored Jan 30, 2021
1 parent 435aa56 commit efd8d0d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
6 changes: 3 additions & 3 deletions nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ $(CsWinRTFilters)
<CompilerVisibleProperty Include="AssemblyVersion" />
<CompilerVisibleProperty Include="CsWinRTComponent" />
<CompilerVisibleProperty Include="CsWinRTEnableLogging" />
<CompilerVisibleProperty Include="GeneratedFilesDir" />
<CompilerVisibleProperty Include="CsWinRTGeneratedFilesDir" />
<CompilerVisibleProperty Include="CsWinRTExe" />
<CompilerVisibleProperty Include="CsWinRTKeepGeneratedSources" />
<CompilerVisibleProperty Include="CsWinRTWindowsMetadata" />
Expand All @@ -131,7 +131,7 @@ $(CsWinRTFilters)
</ItemGroup>

<!-- Note this runs before the msbuild editor config file is generated because that is what is used to pass properties to the source generator. -->
<Target Name="CsWinRTSetAuthoringWinMDs" BeforeTargets="GenerateMSBuildEditorConfigFile;GenerateMSBuildEditorConfigFileCore" DependsOnTargets="CsWinRTRemoveWinMDReferences" Condition="$(CsWinRTEnabled)">
<Target Name="CsWinRTSetAuthoringWinMDs" BeforeTargets="GenerateMSBuildEditorConfigFile;GenerateMSBuildEditorConfigFileCore" DependsOnTargets="CsWinRTRemoveWinMDReferences;GetAssemblyVersion;CsWinRTPrepareProjection" Condition="$(CsWinRTEnabled) And '$(CsWinRTComponent)' == 'true'">
<PropertyGroup>
<CsWinRTAuthoringInputs>$(CsWinRTAuthoringInputs) @(CsWinRTInputs->'"%(FullPath)"', ' ') @(CsWinRTAuthoringWinMDs->'"%(FullPath)"', ' ')</CsWinRTAuthoringInputs>
</PropertyGroup>
Expand All @@ -141,7 +141,7 @@ $(CsWinRTFilters)

<!-- Copy Authored winmd to output folder -->
<Target Name="CsWinRTPlaceWinMDInOutputFolder" Condition="'$(CsWinRTComponent)' == 'true'" BeforeTargets="AfterBuild">
<Copy SourceFiles="$(GeneratedFilesDir)\$(AssemblyName).winmd" DestinationFolder="$(TargetDir)" UseHardlinksIfPossible="false" SkipUnchangedFiles="true" />
<Copy SourceFiles="$(CsWinRTGeneratedFilesDir)\$(AssemblyName).winmd" DestinationFolder="$(TargetDir)" UseHardlinksIfPossible="false" SkipUnchangedFiles="true" />
</Target>

<!-- When an authored component makes a nupkg, add the necessary hosting assets to the package -->
Expand Down
3 changes: 1 addition & 2 deletions src/Authoring/WinRT.SourceGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ private static string GetAssemblyVersion(GeneratorExecutionContext context)

internal static string GetGeneratedFilesDir(GeneratorExecutionContext context)
{
// TODO: determine correct location to write to.
context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.GeneratedFilesDir", out var generatedFilesDir);
context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.CsWinRTGeneratedFilesDir", out var generatedFilesDir);
Directory.CreateDirectory(generatedFilesDir);
return generatedFilesDir;
}
Expand Down
8 changes: 2 additions & 6 deletions src/Tests/AuthoringTest/AuthoringTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Platforms>x64;x86</Platforms>
<LangVersion>preview</LangVersion>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<CsWinRTEnableLogging>true</CsWinRTEnableLogging>
<CsWinRTComponent>true</CsWinRTComponent>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GeneratedFilesDir Condition="'$(GeneratedFilesDir)'==''">$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)', '$(IntermediateOutputPath)', 'Generated Files'))</GeneratedFilesDir>
<!-- Enable to diagnose generation issues -->
<!-- <CsWinRTEnableLogging>true</CsWinRTEnableLogging> -->
<!-- <CsWinRTKeepGeneratedSources>true</CsWinRTKeepGeneratedSources> -->
</PropertyGroup>

Expand All @@ -23,7 +19,7 @@
<CsWinRTAuthoringWinMDs Include="$(NuGetPackageRoot)\microsoft.winui\3.0.0-preview3.201113.0\lib\uap10.0\Microsoft.Web.WebView2.Core.winmd" />
</ItemGroup>

<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Projections\Windows\Windows.csproj" />
<ProjectReference Include="..\..\Projections\WinUI\WinUI.csproj" />
<ProjectReference Include="..\..\Authoring\WinRT.SourceGenerator\WinRT.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
Expand Down

0 comments on commit efd8d0d

Please sign in to comment.