Skip to content

Commit

Permalink
add ability to share debug/release generated files (#325)
Browse files Browse the repository at this point in the history
* add ability to share debug/release generated files (restore original dev workflow)

* fixed issue with prerelease verify target and clarified debug/release projection builds
  • Loading branch information
Scottj1s authored Jun 23, 2020
1 parent 94e6db0 commit 281e536
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<GeneratedFilesDir>$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)', 'Generated Files'))</GeneratedFilesDir>
</PropertyGroup>

<Import Project="nuget\Microsoft.Windows.CsWinRT.targets" />

</Project>
8 changes: 4 additions & 4 deletions Projections/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@
</ItemGroup>
<PropertyGroup>
<CsWinRTVerbosity>high</CsWinRTVerbosity>
<CsWinRTResponseFile>$(IntermediateOutputPath)cswinrt_test.rsp</CsWinRTResponseFile>
<CsWinRTResponseFile>$(GeneratedFilesDir)cswinrt_test.rsp</CsWinRTResponseFile>
<CsWinRTCommand>$(CsWinRTExe) %40"$(CsWinRTResponseFile)"</CsWinRTCommand>
</PropertyGroup>
<PropertyGroup>
<CsWinRTParams>
-verbose
-in 10.0.18362.0
-in @(ReferenceWinMDs->'"%(FullPath)"', ' ')
-out "$(IntermediateOutputPath)Generated Files"
-out "$(GeneratedFilesDir.TrimEnd('\'))"
-exclude Windows
-exclude Microsoft
-include TestComponent
-include TestComponentCSharp
</CsWinRTParams>
</PropertyGroup>
<MakeDir Directories="$(IntermediateOutputPath)Generated Files" />
<MakeDir Directories="$(GeneratedFilesDir)" />
<WriteLinesToFile File="$(CsWinRTResponseFile)" Lines="$(CsWinRTParams)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<Message Text="$(CsWinRTCommand)" Importance="$(CsWinRTVerbosity)" />
<Exec Command="$(CsWinRTCommand)" />
Expand All @@ -71,7 +71,7 @@
<PkgMicrosoft_WinUI Condition="'$(PkgMicrosoft_WinUI)'==''">$([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'microsoft.winui', '$(MicrosoftWinUIVersion)'))</PkgMicrosoft_WinUI>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(IntermediateOutputPath)Generated Files/*.cs" Exclude="@(Compile)" />
<Compile Include="$(GeneratedFilesDir)*.cs" Exclude="@(Compile)" />
<!--Remove references to projection source winmds to prevent compile conflict warnings-->
<ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)" Condition="%(ReferencePathWithRefAssemblies.Filename) == 'TestComponent'" />
<ReferencePathWithRefAssemblies Remove="@(ReferencePathWithRefAssemblies)" Condition="%(ReferencePathWithRefAssemblies.Filename) == 'TestComponentCSharp'" />
Expand Down
8 changes: 4 additions & 4 deletions Projections/WinUI/WinUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
</ItemGroup>
<PropertyGroup>
<CsWinRTVerbosity>high</CsWinRTVerbosity>
<CsWinRTResponseFile>$(IntermediateOutputPath)cswinrt_winui.rsp</CsWinRTResponseFile>
<CsWinRTResponseFile>$(GeneratedFilesDir)cswinrt_winui.rsp</CsWinRTResponseFile>
<CsWinRTCommand>$(CsWinrtExe) %40"$(CsWinRTResponseFile)"</CsWinRTCommand>
</PropertyGroup>
<PropertyGroup>
<CsWinRTParams>
-verbose
-in 10.0.18362.0
-in @(ReferenceWinMDs->'"%(FullPath)"', ' ')
-out "$(IntermediateOutputPath)Generated Files"
-out "$(GeneratedFilesDir.TrimEnd('\'))"
-exclude Windows
-include Microsoft
# The current WinUI nuget incorrectly references several Windows.* types that should be
Expand All @@ -68,15 +68,15 @@
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute
</CsWinRTParams>
</PropertyGroup>
<MakeDir Directories="$(IntermediateOutputPath)Generated Files" />
<MakeDir Directories="$(GeneratedFilesDir)" />
<WriteLinesToFile File="$(CsWinRTResponseFile)" Lines="$(CsWinRTParams)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<Message Text="$(CsWinRTCommand)" Importance="$(CsWinRTVerbosity)" />
<Exec Command="$(CsWinRTCommand)" />
</Target>

<Target Name="IncludeProjection" DependsOnTargets="GenerateProjection" BeforeTargets="CoreCompile">
<ItemGroup>
<Compile Include="$(IntermediateOutputPath)Generated Files/*.cs" Exclude="@(Compile)" />
<Compile Include="$(GeneratedFilesDir)*.cs" Exclude="@(Compile)" />
</ItemGroup>
</Target>

Expand Down
8 changes: 4 additions & 4 deletions Projections/Windows/Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<Target Name="GenerateProjection" Condition="'$(GenerateTestProjection)' == 'true'">
<PropertyGroup>
<CsWinRTVerbosity>high</CsWinRTVerbosity>
<CsWinRTResponseFile>$(IntermediateOutputPath)cswinrt_windows.rsp</CsWinRTResponseFile>
<CsWinRTResponseFile>$(GeneratedFilesDir)cswinrt_windows.rsp</CsWinRTResponseFile>
<CsWinRTCommand>$(CsWinrtExe) %40"$(CsWinRTResponseFile)"</CsWinRTCommand>
</PropertyGroup>
<PropertyGroup>
<CsWinRTParams>
-verbose
-in 10.0.18362.0
-out "$(IntermediateOutputPath)Generated Files"
-out "$(GeneratedFilesDir.TrimEnd('\'))"
-include Windows
# Exclude causality types colliding with those in System.Private.CoreLib.dll
-exclude Windows.Foundation.Diagnostics
Expand All @@ -61,15 +61,15 @@
-include Windows.UI.Xaml.Media.Animation.ConditionallyIndependentlyAnimatableAttribute
</CsWinRTParams>
</PropertyGroup>
<MakeDir Directories="$(IntermediateOutputPath)Generated Files" />
<MakeDir Directories="$(GeneratedFilesDir)" />
<WriteLinesToFile File="$(CsWinRTResponseFile)" Lines="$(CsWinRTParams)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<Message Text="$(CsWinRTCommand)" Importance="$(CsWinRTVerbosity)" />
<Exec Command="$(CsWinRTCommand)" />
</Target>

<Target Name="IncludeProjection" DependsOnTargets="GenerateProjection" BeforeTargets="CoreCompile">
<ItemGroup>
<Compile Include="$(IntermediateOutputPath)Generated Files/*.cs" Exclude="@(Compile)" />
<Compile Include="$(GeneratedFilesDir)*.cs" Exclude="@(Compile)" />
</ItemGroup>
</Target>

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ C#/WinRT currently requires the following packages to build:

The build.cmd script takes care of all related configuration steps and is the simplest way to get started building C#/WinRT. The build script is intended to be executed from a Visual Studio Developer command prompt. It installs prerequisites such as nuget and the .NET 5 SDK, configures the environment to use .NET 5 (creating a global.json if necessary), builds the compiler, and builds and executes the unit tests.

After a successful command-line build, the cswinrt.sln can be launched from the same command prompt, to inherit the necessary environment. By default, the UnitTest and WinUIProjection projections are only generated for Release configurations, where cswinrt.exe can execute in seconds. For Debug configurations, projection generation must be turned on with the project property GenerateTestProjection.
After a successful command-line build, the cswinrt.sln can be launched from the same command prompt, to inherit the necessary environment.

**Note:** By default, projection projects only generate source files for Release configurations, where cswinrt.exe can execute in seconds. To generate projection sources for Debug configurations, set the project property GenerateTestProjection to 'true'. In either case, existing projection sources under the "Generated Files" folder will still be compiled into the projection assembly. This configuration permits a faster inner loop in Visual Studio.

# Structure
The C#/WinRT compiler and unit tests are all contained within the Visual Studio 2019 solution file, \cswinrt\cswinrt.sln.
Expand Down
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ rem Generate prerelease targets file to exercise build warnings
set prerelease_targets=nuget\Microsoft.Windows.CsWinRT.Prerelease.targets
if not exist %prerelease_targets% (
echo Creating default %prerelease_targets%
echo ^<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="CsWinRTVerifyPrerelease"^> > %prerelease_targets%
echo ^<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" InitialTargets="CsWinRTVerifyPrerelease"^> > %prerelease_targets%
echo ^<Target Name="CsWinRTVerifyPrerelease" >> %prerelease_targets%
echo ^Condition="'$(Net5SdkVersion)' ^!= '%CsWinRTNet5SdkVersion%' or '$(MSBuildVersion)' ^!= '%CsWinRTMSBuildVersion%'"^> >> %prerelease_targets%
echo ^<Warning Text="This C#/WinRT prerelease is designed for .Net SDK %CsWinRTNet5SdkVersion% and MSBuild %CsWinRTMSBuildVersion%. Other prerelease combinations may be incompatible due to breaking changes." /^> >> %prerelease_targets%
Expand Down
4 changes: 3 additions & 1 deletion nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ Copyright (C) Microsoft Corporation. All rights reserved.
-->
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!--Remove Windows.Winmd reference to prevent compile collisions-->
<PropertyGroup>
<GeneratedFilesDir Condition="'$(GeneratedFilesDir)'==''">$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)', '$(IntermediateOutputPath)', 'Generated Files'))</GeneratedFilesDir>
<ResolveAssemblyReferencesDependsOn Condition="'$(RemoveWindowsReference)'=='true'">$(ResolveAssemblyReferencesDependsOn);RemoveWindowsReference</ResolveAssemblyReferencesDependsOn>
</PropertyGroup>

<!--Remove Windows.Winmd reference to prevent compile collisions-->
<Target Name="RemoveWindowsReference" Outputs="@(Reference)">
<ItemGroup>
<Reference Remove="Windows"/>
Expand Down

0 comments on commit 281e536

Please sign in to comment.