diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e7cc2173..2a90e2aad 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,29 +1,29 @@ # C#/WinRT Contributor's Guide -Below is our guidance for how to build the repo, report issues, propose new features, and submit contributions via Pull Requests (PRs). +Below is our guidance for how to build the repo, report issues, propose new features, and submit contributions via Pull Requests (PRs). ## Building the C#/WinRT repo C#/WinRT currently requires the following packages, or newer, to build: -- [Visual Studio 17.0](https://visualstudio.microsoft.com/downloads/) -- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) +- [Visual Studio 17.0](https://visualstudio.microsoft.com/downloads/) +- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) - [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1) -- [nuget.exe 5.8.0-preview.3](https://www.nuget.org/downloads) +- [nuget.exe 6.3.1](https://www.nuget.org/downloads) - Microsoft.WinUI 3.0.0-preview4.210210.4 - Microsoft.WindowsAppSDK 1.1.5 -The [`build.cmd`](src/build.cmd) script takes care of all related configuration steps and is the simplest way to get started building C#/WinRT. It installs prerequisites such as `nuget.exe` and the .NET 6 SDK, configures the environment to use .NET 6 (creating a `global.json` if necessary), builds the compiler, and builds and executes the unit tests. To build C#/WinRT, follow these steps: +The [`build.cmd`](src/build.cmd) script takes care of all related configuration steps and is the simplest way to get started building C#/WinRT. It installs prerequisites such as `nuget.exe` and the .NET 6 SDK, configures the environment to use .NET 6 (creating a `global.json` if necessary), builds the compiler, and builds and executes the unit tests. To build C#/WinRT, follow these steps: - Open a Visual Studio Developer command prompt pointing at the repo. -- Run `src\build.cmd`. +- Run `src\build.cmd`. - To launch the project in Visual Studio, run `devenv src\cswinrt.sln` from the same command prompt. This will inherit the necessary environment. **Note:** By default, the projects for various [Projections](src/Projections) only generate source files for Release configurations, where `cswinrt.exe` can execute in seconds. To generate sources for the [Projections](src/Projections) projects on Debug configurations, set the project property `GenerateTestProjection` to `true`. This configuration permits a faster inner loop in Visual Studio. In either case, existing projection sources under the "Generated Files" folder will still be compiled into the projection assembly. ### Customizing `build.cmd` options -There are several settings that can be set with `build.cmd` that you might not know about without studying the code. The build settings and defaults are as follows. +There are several settings that can be set with `build.cmd` that you might not know about without studying the code. The build settings and defaults are as follows. ```cmd build.cmd [Platform] [Configuration] [VersionNumber] [VersionString] [AssemblyVersion] @@ -32,7 +32,7 @@ build.cmd [Platform] [Configuration] [VersionNumber] [VersionString] [AssemblyVe | Parameter | Value(s) | |-|-| | Platform | *x64 \| x86 | Default is `x64` -| Configuration | *Release \| Debug | +| Configuration | *Release \| Debug | | VersionNumber | *0.0.0.0 | | VersionString | *0.0.0-private.0 | | AssemblyVersion | *0.0.0.0 | @@ -52,7 +52,7 @@ build.cmd [Platform] [Configuration] [VersionNumber] [VersionString] [AssemblyVe ```cmd build.cmd x64 Debug 2.0.0.0 2.0.0-mycswinrt.0 2.0.0.0 ``` - This is useful if you want to quickly confirm that your private .nupkg is being used by checking the `WinRT.Runtime` assembly version. + This is useful if you want to quickly confirm that your private .nupkg is being used by checking the `WinRT.Runtime` assembly version. ## Before you start, file an issue @@ -117,4 +117,4 @@ Once your code has been reviewed and approved by the requisite number of team me ## Thank you -Thank you in advance for your contribution! +Thank you in advance for your contribution! diff --git a/src/Authoring/WinRT.Host/WinRT.Host.vcxproj b/src/Authoring/WinRT.Host/WinRT.Host.vcxproj index 2dd3c14d0..a2ae6768b 100644 --- a/src/Authoring/WinRT.Host/WinRT.Host.vcxproj +++ b/src/Authoring/WinRT.Host/WinRT.Host.vcxproj @@ -1,6 +1,6 @@ - + Debug @@ -39,7 +39,7 @@ v143 v142 Unicode - + true @@ -285,14 +285,14 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + \ No newline at end of file diff --git a/src/Authoring/WinRT.Host/WinRT.Host.vcxproj.filters b/src/Authoring/WinRT.Host/WinRT.Host.vcxproj.filters index 929bfabcf..ce8315a10 100644 --- a/src/Authoring/WinRT.Host/WinRT.Host.vcxproj.filters +++ b/src/Authoring/WinRT.Host/WinRT.Host.vcxproj.filters @@ -46,8 +46,8 @@ Source Files - + diff --git a/src/Authoring/WinRT.Host/packages.config b/src/Authoring/WinRT.Host/packages.config index 81f107b8b..cf213dffc 100644 --- a/src/Authoring/WinRT.Host/packages.config +++ b/src/Authoring/WinRT.Host/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/Authoring/WinRT.SourceGenerator/WinRT.SourceGenerator.csproj b/src/Authoring/WinRT.SourceGenerator/WinRT.SourceGenerator.csproj index dd02d9c1e..9839ab6f1 100644 --- a/src/Authoring/WinRT.SourceGenerator/WinRT.SourceGenerator.csproj +++ b/src/Authoring/WinRT.SourceGenerator/WinRT.SourceGenerator.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/src/Authoring/cswinmd/CsWinMD.csproj b/src/Authoring/cswinmd/CsWinMD.csproj index bc34bfbe1..69bc450ad 100644 --- a/src/Authoring/cswinmd/CsWinMD.csproj +++ b/src/Authoring/cswinmd/CsWinMD.csproj @@ -23,8 +23,8 @@ - - + + diff --git a/src/Benchmarks/Benchmarks.csproj b/src/Benchmarks/Benchmarks.csproj index bf67fec8d..2e52f1408 100644 --- a/src/Benchmarks/Benchmarks.csproj +++ b/src/Benchmarks/Benchmarks.csproj @@ -17,10 +17,10 @@ - - - - + + + + diff --git a/src/Samples/NetProjectionSample/README.md b/src/Samples/NetProjectionSample/README.md index 9ecb94551..83e1457a0 100644 --- a/src/Samples/NetProjectionSample/README.md +++ b/src/Samples/NetProjectionSample/README.md @@ -10,7 +10,7 @@ This sample demonstrates how to do the following: * [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) with the Universal Windows Platform development workload installed. In **Installation Details** > **Universal Windows Platform development**, check the **C++ (v14x) Universal Windows Platform tools** option. * [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) -* nuget.exe 5.8.0-preview.2 or later (for command line MSBuild) +* nuget.exe 6.3.1 or later (for command line MSBuild) **Note**: This sample uses .NET 6 and therefore requires Visual Studio 2022 to build and run. If you prefer, you can use Visual Studio 2019 and modify the sample to target [.NET 5](https://dotnet.microsoft.com/download/dotnet/5.0). To do this, you will need to modify the `TargetFramework` and the *nuspec* file in the `SimpleMathProjection` project to target `net5.0-windows10.0.19041.0`. @@ -19,7 +19,7 @@ This sample demonstrates how to do the following: For building in Visual Studio: 1. Open *CppWinRTComponentProjectionSample.sln* in Visual Studio. Ensure that *SimpleMathProjection* is set as the startup project, and set the Platform and Configuration to x64 and Release. Right click on the solution and build. This will do the following: - - Build *SimpleMathComponent*: this will generate *SimpleMathComponent.winmd* and *SimpleMathComponent.dll* + - Build *SimpleMathComponent*: this will generate *SimpleMathComponent.winmd* and *SimpleMathComponent.dll* - Generate the projection interop assembly for the component using C#/WinRT, *SimpleMathProjection.dll* - Generate a NuGet package for the component. To ensure the solution has built successfully, navigate to the *SimpleMathProjection/nuget* folder in your file explorer. You should see the generated NuGet package (*SimpleMathComponent.0.1.0-prerelease.nupkg*). which can be referenced by C# .NET app consumers. diff --git a/src/Samples/TestEmbedded/build.cmd b/src/Samples/TestEmbedded/build.cmd index 87520aed5..493795bca 100644 --- a/src/Samples/TestEmbedded/build.cmd +++ b/src/Samples/TestEmbedded/build.cmd @@ -22,7 +22,7 @@ if exist %nuget_dir%\nuget.exe ( ) ) if not exist %nuget_dir% md %nuget_dir% -if not exist %nuget_dir%\nuget.exe powershell -Command "Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v5.8.0-preview.2/nuget.exe -OutFile %nuget_dir%\nuget.exe" +if not exist %nuget_dir%\nuget.exe powershell -Command "Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v6.3.1/nuget.exe -OutFile %nuget_dir%\nuget.exe" %nuget_dir%\nuget update -self call :exec %nuget_dir%\nuget.exe restore %nuget_params% %this_dir%TestEmbedded.sln diff --git a/src/Samples/WinUIDesktopSample/WinUIDesktopSample.csproj b/src/Samples/WinUIDesktopSample/WinUIDesktopSample.csproj index 037178e62..1bf46201e 100644 --- a/src/Samples/WinUIDesktopSample/WinUIDesktopSample.csproj +++ b/src/Samples/WinUIDesktopSample/WinUIDesktopSample.csproj @@ -23,7 +23,7 @@ - + - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + \ No newline at end of file diff --git a/src/Tests/CSWinMDComponent/packages.config b/src/Tests/CSWinMDComponent/packages.config index 43182aa87..d01b35b3f 100644 --- a/src/Tests/CSWinMDComponent/packages.config +++ b/src/Tests/CSWinMDComponent/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/Tests/DiagnosticTests/DiagnosticTests.csproj b/src/Tests/DiagnosticTests/DiagnosticTests.csproj index f7667f79b..c1c1ff655 100644 --- a/src/Tests/DiagnosticTests/DiagnosticTests.csproj +++ b/src/Tests/DiagnosticTests/DiagnosticTests.csproj @@ -6,11 +6,11 @@ - - - - - + + + + + diff --git a/src/Tests/HostTest/HostTest.vcxproj b/src/Tests/HostTest/HostTest.vcxproj index dfd15efad..a9c2074fd 100644 --- a/src/Tests/HostTest/HostTest.vcxproj +++ b/src/Tests/HostTest/HostTest.vcxproj @@ -1,8 +1,8 @@  + + - - Debug @@ -226,10 +226,10 @@ - - - + + + @@ -328,12 +328,12 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + + + + + \ No newline at end of file diff --git a/src/Tests/HostTest/packages.config b/src/Tests/HostTest/packages.config index 88723859e..73f3845ba 100644 --- a/src/Tests/HostTest/packages.config +++ b/src/Tests/HostTest/packages.config @@ -1,7 +1,7 @@  - - - + + + \ No newline at end of file diff --git a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj index 8f6a8028d..ab0ab85a3 100644 --- a/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj +++ b/src/Tests/TestComponentCSharp/TestComponentCSharp.vcxproj @@ -1,8 +1,8 @@ + + - - high true @@ -125,19 +125,19 @@ - - + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + + + + \ No newline at end of file diff --git a/src/Tests/TestComponentCSharp/packages.config b/src/Tests/TestComponentCSharp/packages.config index f1bb47ee8..48ef7cb89 100644 --- a/src/Tests/TestComponentCSharp/packages.config +++ b/src/Tests/TestComponentCSharp/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/src/Tests/UnitTest/UnitTest.csproj b/src/Tests/UnitTest/UnitTest.csproj index e179c9eaa..bc11c2804 100644 --- a/src/Tests/UnitTest/UnitTest.csproj +++ b/src/Tests/UnitTest/UnitTest.csproj @@ -21,19 +21,19 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/WinRT.Runtime/WinRT.Runtime.csproj b/src/WinRT.Runtime/WinRT.Runtime.csproj index 9e44aa0e4..ed7f0214f 100644 --- a/src/WinRT.Runtime/WinRT.Runtime.csproj +++ b/src/WinRT.Runtime/WinRT.Runtime.csproj @@ -40,9 +40,9 @@ - + - + diff --git a/src/build.cmd b/src/build.cmd index 30ab2e56c..330796b6c 100644 --- a/src/build.cmd +++ b/src/build.cmd @@ -100,17 +100,17 @@ echo ^ >> %prerelease_targets% echo ^ >> %prerelease_targets% goto :skip_build_tools -rem VS 16.X BuildTools support (when a prerelease VS is required, until it is deployed to Azure Devops agents) +rem VS 16.X BuildTools support (when a prerelease VS is required, until it is deployed to Azure Devops agents) msbuild -ver | findstr 16.X >nul if ErrorLevel 1 ( - echo Using VS Build Tools 16.X + echo Using VS Build Tools 16.X if %cswinrt_platform%==x86 ( set msbuild_path="%this_dir%.buildtools\MSBuild\Current\Bin\\" ) else ( set msbuild_path="%this_dir%.buildtools\MSBuild\Current\Bin\amd64\\" ) if not exist !msbuild_path! ( - if not exist .buildtools md .buildtools + if not exist .buildtools md .buildtools powershell -NoProfile -ExecutionPolicy unrestricted -File .\get_buildtools.ps1 ) set nuget_params=-MSBuildPath !msbuild_path! @@ -125,7 +125,7 @@ set nuget_dir=%this_dir%.nuget if not "%cswinrt_label%"=="" goto %cswinrt_label% :restore -rem When a preview nuget is required, update -self doesn't work, so manually update +rem When a preview nuget is required, update -self doesn't work, so manually update if exist %nuget_dir%\nuget.exe ( %nuget_dir%\nuget.exe | findstr 5.9 >nul if ErrorLevel 1 ( @@ -134,7 +134,7 @@ if exist %nuget_dir%\nuget.exe ( ) ) if not exist %nuget_dir% md %nuget_dir% -if not exist %nuget_dir%\nuget.exe powershell -Command "Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v5.8.0-preview.2/nuget.exe -OutFile %nuget_dir%\nuget.exe" +if not exist %nuget_dir%\nuget.exe powershell -Command "Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v6.3.1/nuget.exe -OutFile %nuget_dir%\nuget.exe" %nuget_dir%\nuget update -self rem Note: packages.config-based (vcxproj) projects do not support msbuild /t:restore call %this_dir%get_testwinrt.cmd @@ -146,7 +146,7 @@ call :exec %msbuild_path%msbuild.exe %this_dir%\Tests\ObjectLifetimeTests\Object :build echo Building cswinrt for %cswinrt_platform% %cswinrt_configuration% -call :exec %msbuild_path%msbuild.exe %cswinrt_build_params% /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%;VersionNumber=%cswinrt_version_number%;VersionString=%cswinrt_version_string%;AssemblyVersionNumber=%cswinrt_assembly_version%;GenerateTestProjection=true;BaselineAllAPICompatError=%cswinrt_baseline_breaking_compat_errors%;BaselineAllMatchingRefApiCompatError=%cswinrt_baseline_assembly_version_compat_errors% %this_dir%cswinrt.sln +call :exec %msbuild_path%msbuild.exe %cswinrt_build_params% /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration%;VersionNumber=%cswinrt_version_number%;VersionString=%cswinrt_version_string%;AssemblyVersionNumber=%cswinrt_assembly_version%;GenerateTestProjection=true;BaselineAllAPICompatError=%cswinrt_baseline_breaking_compat_errors%;BaselineAllMatchingRefApiCompatError=%cswinrt_baseline_assembly_version_compat_errors% %this_dir%cswinrt.sln if ErrorLevel 1 ( echo. echo ERROR: Build failed @@ -196,7 +196,7 @@ if not exist %dotnet_exe% ( ) :embeddedtests -:: build the embedded sample and run the unittest +:: build the embedded sample and run the unittest call :exec %dotnet_exe% test --verbosity normal --no-build --logger xunit;LogFilePath=%~dp0embedunittest_%cswinrt_version_string%.xml %this_dir%Samples/TestEmbedded/UnitTestEmbedded/UnitTestEmbedded.csproj /nologo /m /p:platform=%cswinrt_platform%;configuration=%cswinrt_configuration% -- RunConfiguration.TreatNoTestsAsError=true if ErrorLevel 1 ( echo. @@ -208,7 +208,7 @@ if ErrorLevel 1 ( rem Running Object Lifetime Unit Tests echo Running object lifetime tests for %cswinrt_platform% %cswinrt_configuration% if '%NUGET_PACKAGES%'=='' set NUGET_PACKAGES=%USERPROFILE%\.nuget\packages -call :exec vstest.console.exe %this_dir%\Tests\ObjectLifetimeTests\bin\%cswinrt_platform%\%cswinrt_configuration%\net7.0-windows10.0.19041.0\win10-%cswinrt_platform%\ObjectLifetimeTests.Lifted.build.appxrecipe /TestAdapterPath:"%NUGET_PACKAGES%\mstest.testadapter\2.2.4-preview-20210513-02\build\_common" /framework:FrameworkUap10 /logger:trx;LogFileName=%this_dir%\VsTestResults.trx +call :exec vstest.console.exe %this_dir%\Tests\ObjectLifetimeTests\bin\%cswinrt_platform%\%cswinrt_configuration%\net7.0-windows10.0.19041.0\win10-%cswinrt_platform%\ObjectLifetimeTests.Lifted.build.appxrecipe /TestAdapterPath:"%NUGET_PACKAGES%\mstest.testadapter\2.2.4-preview-20210513-02\build\_common" /framework:FrameworkUap10 /logger:trx;LogFileName=%this_dir%\VsTestResults.trx if ErrorLevel 1 ( echo. echo ERROR: Lifetime test failed, skipping NuGet pack @@ -231,17 +231,17 @@ if ErrorLevel 1 ( :hosttest rem Run WinRT.Host tests echo Running cswinrt host tests for %cswinrt_platform% %cswinrt_configuration% -call :exec %this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\HostTest\bin\HostTest.exe --gtest_output=xml:%this_dir%hosttest_%cswinrt_version_string%.xml +call :exec %this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\HostTest\bin\HostTest.exe --gtest_output=xml:%this_dir%hosttest_%cswinrt_version_string%.xml if ErrorLevel 1 ( echo. echo ERROR: Host test failed, skipping NuGet pack exit /b !ErrorLevel! ) - + :authortest rem Run Authoring tests echo Running cswinrt authoring tests for %cswinrt_platform% %cswinrt_configuration% -call :exec %this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\AuthoringConsumptionTest\bin\AuthoringConsumptionTest.exe --gtest_output=xml:%this_dir%hosttest_%cswinrt_version_string%.xml +call :exec %this_dir%_build\%cswinrt_platform%\%cswinrt_configuration%\AuthoringConsumptionTest\bin\AuthoringConsumptionTest.exe --gtest_output=xml:%this_dir%hosttest_%cswinrt_version_string%.xml if ErrorLevel 1 ( echo. echo ERROR: Authoring test failed, skipping NuGet pack @@ -292,4 +292,4 @@ echo. ) else ( %* ) -goto :eof \ No newline at end of file +goto :eof diff --git a/src/cswinrt/cswinrt.vcxproj b/src/cswinrt/cswinrt.vcxproj index 674c12582..408286080 100644 --- a/src/cswinrt/cswinrt.vcxproj +++ b/src/cswinrt/cswinrt.vcxproj @@ -1,7 +1,7 @@  + - 15.0 {6acfd2b2-e8aa-4cd4-aad8-213ce8bb2637} @@ -125,8 +125,8 @@ This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. - + \ No newline at end of file diff --git a/src/cswinrt/packages.config b/src/cswinrt/packages.config index 293ccb4f7..6e5bd112e 100644 --- a/src/cswinrt/packages.config +++ b/src/cswinrt/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file