Skip to content

Commit a4f58aa

Browse files
authored
Fix MSTest version under testing platform (#2630)
1 parent 3beee7a commit a4f58aa

File tree

7 files changed

+39
-20
lines changed

7 files changed

+39
-20
lines changed

src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,35 @@
8484
</None>
8585
</ItemGroup>
8686

87+
<!-- Insert the MSTestVersion.cs -->
88+
<PropertyGroup>
89+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
90+
</PropertyGroup>
91+
<ItemGroup>
92+
<Compile Include="**/*.cs" Exclude="**/*.user; **/*.*proj; **/*.sln; **/*.vssscc" />
93+
</ItemGroup>
94+
<Target Name="InsertMSTestVersion" BeforeTargets="PrepareForBuild" >
95+
<ItemGroup>
96+
<Compile Include="$(Compile);$(IntermediateOutputPath)/MSTestVersion.cs" />
97+
</ItemGroup>
98+
</Target>
99+
100+
<!-- Version templating -->
101+
<ItemGroup>
102+
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Templating" Version="$(MicrosoftDotNetBuildTasksTemplatingPackageVersion)" AllowExplicitReference="true" PrivateAssets="All" IsImplicitlyDefined="true" />
103+
</ItemGroup>
104+
<Target Name="GenerateMSTestVersionSourceFile" AfterTargets="PrepareForBuild" >
105+
<PropertyGroup>
106+
<_TemplateProperties>Version=$(Version)</_TemplateProperties>
107+
</PropertyGroup>
108+
<ItemGroup>
109+
<_TemplateCsproj Include="$(MSBuildProjectDirectory)/MSTestVersion.cs.template" Destination="$(IntermediateOutputPath)/MSTestVersion.cs" />
110+
</ItemGroup>
111+
<GenerateFileFromTemplate TemplateFile="%(_TemplateCsproj.Identity)" OutputPath="%(_TemplateCsproj.Destination)" Properties="$(_TemplateProperties)">
112+
<Output TaskParameter="ResolvedOutputPath" ItemName="FileWrites" />
113+
</GenerateFileFromTemplate>
114+
</Target>
115+
87116
<!-- SDK bottom import -->
88117
<Import Project="Sdk.targets" Sdk="MSBuild.Sdk.Extras" Condition=" '$(OS)' == 'Windows_NT' " />
89118
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition=" '$(OS)' != 'Windows_NT' " />

src/Platform/Microsoft.Testing.Platform/RepositoryVersion.cs.template renamed to src/Adapter/MSTest.TestAdapter/MSTestVersion.cs.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// <summary>
55
/// Repository version, created at build time.
66
/// </summary>
7-
internal static class RepositoryVersion
7+
internal static class MSTestVersion
88
{
9-
public const string Version = "${Version}";
9+
public const string SemanticVersion = "${Version}";
1010
}

src/Adapter/MSTest.TestAdapter/RepositoryVersion.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/MSTestExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal sealed class MSTestExtension : IExtension
1212

1313
public string DisplayName => "MSTest";
1414

15-
public string Version => RepositoryVersion.Version;
15+
public string Version => MSTestVersion.SemanticVersion;
1616

1717
public string Description => "MSTest Framework for Microsoft Testing Platform";
1818

src/Platform/Microsoft.Testing.Platform/Helpers/AppVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ namespace Microsoft.Testing.Platform.Helpers;
55

66
internal static class AppVersion
77
{
8-
public static readonly string DefaultSemVer = RepositoryVersion.Version;
8+
public static readonly string DefaultSemVer = PlatformVersion.Version;
99
}

src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
<SuppressLicenseValidation>true</SuppressLicenseValidation>
99
</PropertyGroup>
1010

11-
<!-- Insert the RepositoryVersion.cs -->
11+
<!-- Insert the PlatformVersion.cs -->
1212
<PropertyGroup>
1313
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
1414
</PropertyGroup>
1515
<ItemGroup>
1616
<Compile Include="**/*.cs" Exclude="**/*.user; **/*.*proj; **/*.sln; **/*.vssscc" />
1717
</ItemGroup>
18-
<Target Name="InsertRepositoryVersion" BeforeTargets="PrepareForBuild" >
18+
<Target Name="InsertPlatformVersion" BeforeTargets="PrepareForBuild" >
1919
<ItemGroup>
20-
<Compile Include="$(Compile);$(IntermediateOutputPath)/RepositoryVersion.cs" />
20+
<Compile Include="$(Compile);$(IntermediateOutputPath)/PlatformVersion.cs" />
2121
</ItemGroup>
2222
</Target>
2323

@@ -106,12 +106,12 @@ This package provides the core platform and the .NET implementation of the proto
106106
<ItemGroup>
107107
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Templating" Version="$(MicrosoftDotNetBuildTasksTemplatingPackageVersion)" AllowExplicitReference="true" PrivateAssets="All" IsImplicitlyDefined="true" />
108108
</ItemGroup>
109-
<Target Name="GenerateRepositoryVersionSourceFile" AfterTargets="PrepareForBuild" >
109+
<Target Name="GeneratePlatformVersionSourceFile" AfterTargets="PrepareForBuild" >
110110
<PropertyGroup>
111111
<_TemplateProperties>Version=$(Version)</_TemplateProperties>
112112
</PropertyGroup>
113113
<ItemGroup>
114-
<_TemplateCsproj Include="$(MSBuildProjectDirectory)/RepositoryVersion.cs.template" Destination="$(IntermediateOutputPath)/RepositoryVersion.cs" />
114+
<_TemplateCsproj Include="$(MSBuildProjectDirectory)/PlatformVersion.cs.template" Destination="$(IntermediateOutputPath)/PlatformVersion.cs" />
115115
</ItemGroup>
116116
<GenerateFileFromTemplate TemplateFile="%(_TemplateCsproj.Identity)" OutputPath="%(_TemplateCsproj.Destination)" Properties="$(_TemplateProperties)">
117117
<Output TaskParameter="ResolvedOutputPath" ItemName="FileWrites" />

src/Adapter/MSTest.TestAdapter/RepositoryVersion.cs.template renamed to src/Platform/Microsoft.Testing.Platform/PlatformVersion.cs.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// <summary>
55
/// Repository version, created at build time.
66
/// </summary>
7-
internal static class RepositoryVersion
7+
internal static class PlatformVersion
88
{
99
public const string Version = "${Version}";
1010
}

0 commit comments

Comments
 (0)