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

add ability to share debug/release generated files #325

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
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