diff --git a/test/Shared/MsBuildProjectSetupHelper.cs b/test/Shared/MsBuildProjectSetupHelper.cs index 7149e61a47..6fe1259c6a 100644 --- a/test/Shared/MsBuildProjectSetupHelper.cs +++ b/test/Shared/MsBuildProjectSetupHelper.cs @@ -21,6 +21,34 @@ internal class MsBuildProjectSetupHelper private static object _syncObj = new object(); + private static string artifactsDir; + private static string ArtifactsDirectory + { + get + { + if (string.IsNullOrEmpty(artifactsDir)) + { + lock(_syncObj) + { + if (string.IsNullOrEmpty(artifactsDir)) + { + var current = new DirectoryInfo(AppContext.BaseDirectory); + while (current != null) + { + if (File.Exists(Path.Combine(current.FullName, "Scaffolding.sln"))) + { + artifactsDir = Path.Combine(current.FullName, "artifacts", "build"); + break; + } + current = current.Parent; + } + } + } + } + return artifactsDir; + } + } + private string AspNetCoreVersion { get @@ -54,7 +82,10 @@ public void SetupProjects(TemporaryFileProvider fileProvider, ITestOutputHelper { Directory.CreateDirectory(Path.Combine(fileProvider.Root, "Root")); Directory.CreateDirectory(Path.Combine(fileProvider.Root, "Library1")); - + + var propsFileText = string.Format( MsBuildProjectStrings.PropsFileTxt, ""); + fileProvider.Add("Shared.props", propsFileText); + var rootProjectTxt = fullFramework ? MsBuildProjectStrings.RootNet45ProjectTxt : MsBuildProjectStrings.RootProjectTxt; fileProvider.Add($"Root/{MsBuildProjectStrings.RootProjectName}", string.Format(rootProjectTxt, AspNetCoreVersion, CodeGenerationVersion, RuntimeFrameworkVersion, "2.0.1-*")); fileProvider.Add($"Root/Startup.cs", MsBuildProjectStrings.StartupTxt); @@ -99,7 +130,9 @@ public void SetupProjectsWithoutEF(TemporaryFileProvider fileProvider, ITestOutp { Directory.CreateDirectory(Path.Combine(fileProvider.Root, "Root")); Directory.CreateDirectory(Path.Combine(fileProvider.Root, "Library1")); - + var propsFileText = string.Format( MsBuildProjectStrings.PropsFileTxt, ""); + fileProvider.Add("Shared.props", propsFileText); + var rootProjectTxt = MsBuildProjectStrings.RootProjectTxtWithoutEF; fileProvider.Add($"Root/{MsBuildProjectStrings.RootProjectName}", string.Format(rootProjectTxt, AspNetCoreVersion, CodeGenerationVersion, RuntimeFrameworkVersion, "2.0.1-*")); fileProvider.Add($"Root/Startup.cs", MsBuildProjectStrings.StartupTxtWithoutEf); diff --git a/test/Shared/MsBuildProjectStrings.cs b/test/Shared/MsBuildProjectStrings.cs index 68f7a92829..2909e4ec8e 100644 --- a/test/Shared/MsBuildProjectStrings.cs +++ b/test/Shared/MsBuildProjectStrings.cs @@ -9,19 +9,26 @@ namespace Microsoft.VisualStudio.Web.CodeGeneration internal class MsBuildProjectStrings { public const string RootProjectName = "Test.csproj"; - public const string RootProjectTxt = @" - + public const string PropsFileTxt = @" $(DotNetRestoreSources) + {0} $(RestoreSources); https://dotnet.myget.org/F/aspnet-2-0-2-october2017-patch/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; https://api.nuget.org/v3/index.json; + $(ArtifactsDir); + +"; + public const string RootProjectTxt = @" + + + netcoreapp2.0 Microsoft.TestProject TestProject @@ -61,17 +68,8 @@ internal class MsBuildProjectStrings public const string RootProjectTxtWithoutEF = @" - + - $(DotNetRestoreSources) - - $(RestoreSources); - https://dotnet.myget.org/F/aspnet-2-0-2-october2017-patch/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; - https://api.nuget.org/v3/index.json; - - netcoreapp2.0 Microsoft.TestProject TestProject @@ -107,16 +105,8 @@ internal class MsBuildProjectStrings public const string RootNet45ProjectTxt = @" + - $(DotNetRestoreSources) - - $(RestoreSources); - https://dotnet.myget.org/F/aspnet-2-0-2-october2017-patch/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; - https://api.nuget.org/v3/index.json; - - Microsoft.TestProject TestProject EXE @@ -286,16 +276,8 @@ public static void Main(string[] args) public const string LibraryProjectName = "Library1.csproj"; public const string LibraryProjectTxt = @" + - $(DotNetRestoreSources) - - $(RestoreSources); - https://dotnet.myget.org/F/aspnet-2-0-2-october2017-patch/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-master/api/v3/index.json; - https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; - https://api.nuget.org/v3/index.json; - - Microsoft.Library Library1 Library