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

Simplify versioning handling #1879

Merged
merged 2 commits into from
Dec 5, 2023
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
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