Skip to content

Commit 9effdac

Browse files
committed
Update test to work whether or not VS is pre-installed on VM
1 parent b314451 commit 9effdac

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/Tests/dotnet-MsiInstallation.Tests/MsiInstallerTests.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ string SdkInstallerVersion
7474
}
7575
""";
7676

77-
//VMControl VM { get; }
7877
VirtualMachine VM { get; }
7978

8079
public WorkloadTests(ITestOutputHelper log) : base(log)
@@ -171,7 +170,19 @@ public void InstallAndroidAndWasm()
171170
[Fact]
172171
public void SdkInstallation()
173172
{
174-
GetInstalledSdkVersion().Should().Be("7.0.401");
173+
var command = VM.CreateRunCommand("dotnet", "--version");
174+
command.IsReadOnly = true;
175+
176+
string originalSdkVersion;
177+
var versionResult = command.Execute();
178+
if (versionResult.ExitCode == 0)
179+
{
180+
originalSdkVersion = versionResult.StdOut;
181+
}
182+
else
183+
{
184+
originalSdkVersion = null;
185+
}
175186

176187
InstallSdk(deployStage2: false);
177188

@@ -187,7 +198,16 @@ public void SdkInstallation()
187198
.Should()
188199
.NotExist();
189200

190-
GetInstalledSdkVersion().Should().Be("7.0.401");
201+
if (originalSdkVersion != null)
202+
{
203+
GetInstalledSdkVersion().Should().Be(originalSdkVersion);
204+
}
205+
else
206+
{
207+
VM.GetRemoteDirectory($@"c:\Program Files\dotnet")
208+
.Should()
209+
.NotExist();
210+
}
191211
}
192212

193213

0 commit comments

Comments
 (0)