Fix additional tests that need to be manually retargeted at 9 and centralize the current tfm

This commit is contained in:
Marc Paine 2023-09-29 12:53:43 -07:00
parent 6f7b458acc
commit c1b4bc93c3
3 changed files with 18 additions and 4 deletions

View file

@ -16,9 +16,6 @@ namespace EndToEnd.Tests
{
public class ProjectBuildTests : TestBase
{
// This is needed each release after we upgrade to 9.0 but the templates haven't been upgraded yet
private static readonly string currentTfm = "net9.0";
[Fact]
public void ItCanNewRestoreBuildRunCleanMSBuildProject()
{
@ -31,6 +28,15 @@ namespace EndToEnd.Tests
.Execute(newArgs)
.Should().Pass();
string projectPath = Path.Combine(projectDirectory, directory.Name + ".csproj");
var project = XDocument.Load(projectPath);
var ns = project.Root.Name.Namespace;
project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework").Value = TestAssetInfo.currentTfm;
project.Save(projectPath);
new RestoreCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
@ -76,7 +82,7 @@ namespace EndToEnd.Tests
project.Root.Attribute("Sdk").Value = "Microsoft.NET.Sdk.Web";
project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework").Value = currentTfm;
.Element(ns + "TargetFramework").Value = TestAssetInfo.currentTfm;
project.Save(projectPath);
new BuildCommand()