-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathNugetRestoreTests.cs
More file actions
65 lines (60 loc) · 2.36 KB
/
NugetRestoreTests.cs
File metadata and controls
65 lines (60 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Reflection;
using Microsoft.Build.UnitTests;
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using Xunit;
namespace Microsoft.Build.Engine.OM.UnitTests
{
public sealed class NugetRestoreTests
{
private ITestOutputHelper _output;
public NugetRestoreTests(ITestOutputHelper output)
{
_output = output;
}
// Tests proper loading of msbuild assemblies by nuget.exe
[WindowsFullFrameworkOnlyFact]
public void TestOldNuget()
{
TestNugetRestore(string.Empty);
}
[WindowsFullFrameworkOnlyFact]
public void TestOldNugetWithMsBuild64bit()
{
TestNugetRestore("amd64");
}
private void TestNugetRestore(string msbuildSubFolder)
{
string currentAssemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
string bootstrapMsBuildBinaryDir = Path.Combine(RunnerUtilities.BootstrapMsBuildBinaryLocation, msbuildSubFolder);
using TestEnvironment testEnvironment = TestEnvironment.Create();
TransientTestFolder folder = testEnvironment.CreateFolder(createFolder: true);
// The content of the solution isn't known to matter, but having a custom solution makes it easier to add requirements should they become evident.
TransientTestFile sln = testEnvironment.CreateFile(folder, "test.sln",
@"
Microsoft Visual Studio Solution File, Format Version 12.00
\# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
");
RunnerUtilities.RunProcessAndGetOutput(Path.Combine(currentAssemblyDir, "nuget", "NuGet.exe"), "restore " + sln.Path + " -MSBuildPath \"" + bootstrapMsBuildBinaryDir + "\"", out bool success, outputHelper: _output);
success.ShouldBeTrue();
}
}
}