Skip to content

Commit

Permalink
Add experimental MSBuild sdk project (#1864)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoRossignoli authored Dec 4, 2023
1 parent c935954 commit 8e4df46
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,8 @@ project.fragment.lock.json
.dotnet/
.packages/
.tools/

# ===========================
# Update template files
# ===========================
/src/Package/MSTest.Sdk/Sdk/Sdk.props
10 changes: 9 additions & 1 deletion TestFx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{929A3EDE-893B-4801-82BA-01FD947291CB}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
Directory.Build.Local.props = Directory.Build.Local.props
Directory.Build.Local.targets = Directory.Build.Local.targets
Directory.Build.props = Directory.Build.props
Expand Down Expand Up @@ -162,8 +163,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSTest.Internal.TestFx.Docu
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestingPlatformRunner", "TestingPlatformRunner", "{A9F9C49E-3CDA-4207-AA53-CC80AF1798FE}"
ProjectSection(SolutionItems) = preProject
eng\TestingPlatformRunner\TestingPlatformRunner.targets = eng\TestingPlatformRunner\TestingPlatformRunner.targets
eng\TestingPlatformRunner\TestingPlatform.Runner.targets = eng\TestingPlatformRunner\TestingPlatform.Runner.targets
eng\TestingPlatformRunner\TestingPlatformRunner.targets = eng\TestingPlatformRunner\TestingPlatformRunner.targets
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1 - Runner", "1 - Runner", "{6AEE1440-FDF0-4729-8196-B24D0E333550}"
Expand All @@ -172,6 +173,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Testing.Platform"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Testing.Platform.UnitTests", "test\UnitTests\Microsoft.Testing.Platform.UnitTests\Microsoft.Testing.Platform.UnitTests.csproj", "{0F1BB08E-BB6C-43E0-A7DF-1D6A03DA5DC7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSTest.Sdk", "src\Package\MSTest.Sdk\MSTest.Sdk.csproj", "{10930CFD-EDF9-4486-B0A3-49230B5A6798}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -354,6 +357,10 @@ Global
{0F1BB08E-BB6C-43E0-A7DF-1D6A03DA5DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F1BB08E-BB6C-43E0-A7DF-1D6A03DA5DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F1BB08E-BB6C-43E0-A7DF-1D6A03DA5DC7}.Release|Any CPU.Build.0 = Release|Any CPU
{10930CFD-EDF9-4486-B0A3-49230B5A6798}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10930CFD-EDF9-4486-B0A3-49230B5A6798}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10930CFD-EDF9-4486-B0A3-49230B5A6798}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10930CFD-EDF9-4486-B0A3-49230B5A6798}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -417,6 +424,7 @@ Global
{6AEE1440-FDF0-4729-8196-B24D0E333550} = {FF8B1B72-55A1-4FFE-809E-7B79323ED8D0}
{48FAB979-8DA5-492E-8B3F-5DBBE82F659A} = {6AEE1440-FDF0-4729-8196-B24D0E333550}
{0F1BB08E-BB6C-43E0-A7DF-1D6A03DA5DC7} = {BB874DF1-44FE-415A-B634-A6B829107890}
{10930CFD-EDF9-4486-B0A3-49230B5A6798} = {E374A3A6-C364-4890-B315-D60F5C682B6E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {31E0F4D5-975A-41CC-933E-545B2201FAF9}
Expand Down
4 changes: 4 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
<Uri>https://github.com/microsoft/testanywhere</Uri>
<Sha>43bcc485747b0f15894cc7b6bcd0551af58ad21c</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="8.0.0-beta.23428.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>3d92d0bfd8c9006f5fe1687e465dc4f8aa068b00</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
3 changes: 3 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
<MicrosoftCodeAnalysisPublicApiAnalyzersVersion>3.3.4</MicrosoftCodeAnalysisPublicApiAnalyzersVersion>
<MicrosoftCodeAnalysisBannedApiAnalyzersVersion>$(MicrosoftCodeAnalysisPublicApiAnalyzersVersion)</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
<!-- MSBuild Sdk versions updates -->
<MicrosoftDotNetBuildTasksTemplatingPackageVersion>8.0.0-beta.23428.2</MicrosoftDotNetBuildTasksTemplatingPackageVersion>
<MSTestVersion>3.2.0-preview.23601.5</MSTestVersion>
<MicrosoftVisualStudioThreadingAnalyzersVersion>17.7.30</MicrosoftVisualStudioThreadingAnalyzersVersion>
<StrongNamerVersion>0.2.5</StrongNamerVersion>
<StyleCopAnalyzersVersion>1.2.0-beta.507</StyleCopAnalyzersVersion>
Expand Down
1 change: 1 addition & 0 deletions eng/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function Unzip {
function Confirm-NugetPackages {
Write-Verbose "Starting Confirm-NugetPackages."
$expectedNumOfFiles = @{
"MSTest.Sdk" = 7;
"MSTest.Internal.TestFx.Documentation" = 10;
"MSTest.TestFramework" = 94;
"MSTest.TestAdapter" = 154;
Expand Down
45 changes: 45 additions & 0 deletions src/Package/MSTest.Sdk/MSTest.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<IsPackable>true</IsPackable>
<IsShippingPackage>false</IsShippingPackage>
<PackageId>MSTest.Sdk</PackageId>
<NuspecFile>MSTest.Sdk.nuspec</NuspecFile>
<NuspecBasePath>$(OutputPath)</NuspecBasePath>
<PackageTags>MSTest TestFramework TestAdapter VisualStudio Unittest MSTestV2 Microsoft</PackageTags>
<PackageDescription>
MSTest is Microsoft supported Test Framework.

This package contains the MSTest MSBuild project SDK.
</PackageDescription>
<!-- Nothing in lib but that's expected -->
<NoWarn>$(NoWarn);NU5128</NoWarn>
</PropertyGroup>

<ItemGroup>
<Content Include="Sdk\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Templating" Version="$(MicrosoftDotNetBuildTasksTemplatingPackageVersion)" AllowExplicitReference="true" PrivateAssets="All" IsImplicitlyDefined="true" />
</ItemGroup>
<Target Name="GenerateTemplates" AfterTargets="PrepareForBuild">
<PropertyGroup>
<_TemplateProperties>MSTestVersion=$(MSTestVersion);MicrosoftTestingPlatformVersion=$(MicrosoftTestingPlatformVersion);MicrosoftNETTestSdkVersion=$(MicrosoftNETTestSdkVersion)</_TemplateProperties>
</PropertyGroup>
<!-- List all templates that use ${} template, that will be replaced by the properties defined below.
This will happen on every build. When adding a new file, also add the destination fileto .gitignore. -->
<ItemGroup>
<_TemplateCsproj Include="$(MSBuildProjectDirectory)/Sdk/Sdk.props" Destination="$(MSBuildProjectDirectory)/Sdk/Sdk.props" />
</ItemGroup>
<GenerateFileFromTemplate TemplateFile="%(_TemplateCsproj.Identity)" OutputPath="%(_TemplateCsproj.Destination)" Properties="$(_TemplateProperties)">
<Output TaskParameter="ResolvedOutputPath" ItemName="FileWrites" />
</GenerateFileFromTemplate>
</Target>
</Project>
10 changes: 10 additions & 0 deletions src/Package/MSTest.Sdk/MSTest.Sdk.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<package >
<metadata>
$CommonMetadataElements$
</metadata>
<files>
$CommonFileElements$
<file src="netstandard2.0\Sdk\**" target="Sdk" />
</files>
</package>
18 changes: 18 additions & 0 deletions src/Package/MSTest.Sdk/Sdk/Sdk.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<!-- Implicit top import -->
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<UseMSTestRunner>true</UseMSTestRunner>
<TestingPlatformDonetTestSupport>false</TestingPlatformDonetTestSupport>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="${MicrosoftNETTestSdkVersion}" />
<PackageReference Include="MSTest.TestAdapter" Version="${MSTestVersion}" />
<PackageReference Include="MSTest.TestFramework" Version="${MSTestVersion}" />
<PackageReference Include="Microsoft.Testing.Platform.Extensions.VSTestBridge" Version="${MicrosoftTestingPlatformVersion}" />
</ItemGroup>
</Project>
40 changes: 40 additions & 0 deletions src/Package/MSTest.Sdk/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="_SetupEntryPoint" BeforeTargets="GenerateProgramFile" Condition=" '$(UseMSTestRunner)' == 'false' " >
<PropertyGroup>
<!-- Disable testing platform entry point generation -->
<GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>
</PropertyGroup>
<!--
We need to re-enable the VSTest sdk program.* generation by it's by default disabled when we reference Microsoft.Testing.Platform.MSBuild.
We cannot use the GenerateProgramFile property as Microsoft.NET.Test.Sdk.targets it's an 'InitialTargets' and we cannot plug any target before it.
-->
<CallTarget Targets="_GenerateProgramFileTakenFromVSTest" />
</Target>

<!--
============================================================
GenerateProgramFile taken from Microsoft.NET.Test.Sdk.targets
Generates Program file which contains the Main entry point
============================================================
-->
<Target Name="_GenerateProgramFileTakenFromVSTest" >

<ItemGroup Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'">
<RemoveExistingMicrosoftNETTestSdkProgram Include="@(Compile)" Condition="'%(FileName)' == 'Microsoft.NET.Test.Sdk.Program'" />
<Compile Remove="@(RemoveExistingMicrosoftNETTestSdkProgram)" />
<Compile Include="$(GeneratedProgramFile)"/>
</ItemGroup>

<ItemGroup Condition="'$(Language)' == 'F#'">
<ProgramCompiles Include="@(Compile)" Condition="'%(Identity)' == 'Program.fs'" />
<CompileAfter Include="$(GeneratedProgramFile)" Condition="@(ProgramCompiles-&gt;Count()) == 0" />
</ItemGroup>

<Warning Condition="@(ProgramCompiles-&gt;Count()) != 0" Text="A 'Program.fs' file can be automatically generated for F# .NET Core test projects. To fix this warning, either delete the file from the project, or set the &lt;GenerateProgramFile&gt; property to 'false'." />

</Target>

<!-- Implicit bottom import -->
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>

0 comments on commit 8e4df46

Please sign in to comment.