Skip to content

Commit d18e561

Browse files
committed
Fix BuildIntegrationTests to use MSBuildLocation before ctor
The BuildIintegrationTests.ctor itself loads MSBuild when jitting, so we need xunit to invoke the msbuild locator before that. We achieve this with a class fixture.
1 parent 8da6adc commit d18e561

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/NerdBank.GitVersioning.Tests/AssemblyInfoTest.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@
66
using Nerdbank.GitVersioning.Tasks;
77
using Xunit;
88

9-
public class AssemblyInfoTest
9+
public class AssemblyInfoTest : IClassFixture<MSBuildFixture>
1010
{
11-
public AssemblyInfoTest()
12-
{
13-
MSBuildExtensions.LoadMSBuild();
14-
}
15-
1611
[Fact]
1712
public void FSharpGenerator()
1813
{

src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
using Xunit.Abstractions;
2424
using Version = System.Version;
2525

26-
public class BuildIntegrationTests : RepoTestBase
26+
public class BuildIntegrationTests : RepoTestBase, IClassFixture<MSBuildFixture>
2727
{
2828
private const string GitVersioningTargetsFileName = "NerdBank.GitVersioning.targets";
2929
private const string UnitTestCloudBuildPrefix = "UnitTest: ";
@@ -48,8 +48,6 @@ public class BuildIntegrationTests : RepoTestBase
4848
public BuildIntegrationTests(ITestOutputHelper logger)
4949
: base(logger)
5050
{
51-
MSBuildExtensions.LoadMSBuild();
52-
5351
int seed = (int)DateTime.Now.Ticks;
5452
this.random = new Random(seed);
5553
this.Logger.WriteLine("Random seed: {0}", seed);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class MSBuildFixture
2+
{
3+
public MSBuildFixture()
4+
{
5+
MSBuildExtensions.LoadMSBuild();
6+
}
7+
}

0 commit comments

Comments
 (0)