Skip to content

Commit

Permalink
Simplify versioning handling (#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink authored Dec 5, 2023
1 parent 05cd400 commit 6a0895d
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 21 deletions.
6 changes: 0 additions & 6 deletions Directory.Build.Local.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@

<!-- Build config -->
<PropertyGroup>
<!--
It appears that AssemblyVersion should always be set to 14.0.0.0 for some backward compatibility cases,
but we don't have any information about these cases.
-->
<AssemblyVersion>14.0.0.0</AssemblyVersion>
<AssemblyFileVersion>14.0.0.0</AssemblyFileVersion>
<FixupTestingPlatformVersion>true</FixupTestingPlatformVersion>
<!-- Prevent warning about deprecated target frameworks -->
<CheckEolTargetFramework>false</CheckEolTargetFramework>
Expand Down
9 changes: 9 additions & 0 deletions Directory.Build.Local.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@
<TargetFramework Condition=" '$(TargetFramework)' != '' ">$(NetCoreAppLatestStableVersion)</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition=" '$(UseAssemblyVersion14)' == 'true' ">
<!--
It appears that AssemblyVersion should always be set to 14.0.0.0 for some backward compatibility cases,
but we don't have any information about these cases.
-->
<AssemblyVersion>14.0.0.0</AssemblyVersion>
<AssemblyFileVersion>14.0.0.0</AssemblyFileVersion>
</PropertyGroup>

</Project>
1 change: 1 addition & 0 deletions src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;$(NetCoreAppCurrent);$(NetCoreAppMinimum);$(NetFrameworkMinimum)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<UseAssemblyVersion14>true</UseAssemblyVersion14>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>$(UwpMinimum);$(WinUiMinimum);netstandard2.0;$(NetFrameworkMinimum);$(NetCoreAppMinimum);$(NetCoreAppCurrent)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<UseAssemblyVersion14>true</UseAssemblyVersion14>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>$(UwpMinimum);$(WinUiMinimum);netstandard2.0;$(NetCoreAppCurrent);$(NetCoreAppMinimum);$(NetFrameworkMinimum)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<UseAssemblyVersion14>true</UseAssemblyVersion14>
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/TestFramework/TestFramework/TestFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;$(NetCoreAppCurrent);$(NetCoreAppMinimum);$(NetFrameworkMinimum)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<UseAssemblyVersion14>true</UseAssemblyVersion14>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<NetStandardNetFrameworkHolder>net48</NetStandardNetFrameworkHolder>
<TargetFrameworks>net462;$(NetStandardNetFrameworkHolder);netcoreapp3.1;net6.0;$(WinUiMinimum)</TargetFrameworks>
<IsNetCoreApp Condition=" '$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == '$(WinUiMinimum)' ">true</IsNetCoreApp>
<UseAssemblyVersion14>true</UseAssemblyVersion14>
</PropertyGroup>

<!-- Properties specific to WinUI -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ namespace MSTestAdapter.PlatformServices.UnitTests.Utilities;

public class XmlUtilitiesTests : TestContainer
{
private readonly TestableXmlUtilities _testableXmlUtilities;

public XmlUtilitiesTests()
{
_testableXmlUtilities = new TestableXmlUtilities();
}
private readonly TestableXmlUtilities _testableXmlUtilities = new();

public void AddAssemblyRedirectionShouldAddRedirectionToAnEmptyXml()
{
Expand All @@ -35,8 +30,19 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAnEmptyXml()
assemblyName.Version.ToString());

// Assert.
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"MSTestAdapter.PlatformServices.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
var expectedXml = """
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MSTestAdapter.PlatformServices.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var doc = new XmlDocument();
doc.LoadXml(expectedXml);
byte[] expectedConfigBytes = null;
Expand Down Expand Up @@ -64,8 +70,19 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAnEmptyConfig()
assemblyName.Version.ToString());

// Assert.
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"MSTestAdapter.PlatformServices.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
var expectedXml = """
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MSTestAdapter.PlatformServices.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var doc = new XmlDocument();
doc.LoadXml(expectedXml);
byte[] expectedConfigBytes = null;
Expand Down Expand Up @@ -95,8 +112,19 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAConfigWithARuntimeSecti
assemblyName.Version.ToString());

// Assert.
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"MSTestAdapter.PlatformServices.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
var expectedXml = """
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MSTestAdapter.PlatformServices.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var doc = new XmlDocument();
#pragma warning disable CA3075 // Insecure DTD processing in XML
doc.LoadXml(expectedXml);
Expand All @@ -114,7 +142,19 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAConfigWithARuntimeSecti

public void AddAssemblyRedirectionShouldAddRedirectionToAConfigWithRedirections()
{
_testableXmlUtilities.ConfigXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"Random.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
_testableXmlUtilities.ConfigXml = """
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Random.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var assemblyName = Assembly.GetExecutingAssembly().GetName();

var configBytes = _testableXmlUtilities.AddAssemblyRedirection(
Expand All @@ -124,8 +164,23 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAConfigWithRedirections(
assemblyName.Version.ToString());

// Assert.
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"Random.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly><dependentAssembly><assemblyIdentity name=\"MSTestAdapter.PlatformServices.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
var expectedXml = """
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Random.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MSTestAdapter.PlatformServices.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var doc = new XmlDocument();
doc.LoadXml(expectedXml);
byte[] expectedConfigBytes = null;
Expand Down

0 comments on commit 6a0895d

Please sign in to comment.