Merged PR 304: Enable local builds with dotnet/Arcade

[WIP] Enable local builds with dotnet/Arcade
\n\nCommit migrated from 409618521f
This commit is contained in:
Ryan Nowak 2018-12-02 00:25:55 +00:00
parent a5ef5133a3
commit 7df54be754
26 changed files with 151 additions and 74 deletions

View File

@ -5,6 +5,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<PackageTags>$(PackageTags);aspnetcoremvc</PackageTags>
<EnableApiCheck>false</EnableApiCheck>
<IsShipping>false</IsShipping>
</PropertyGroup>
<ItemGroup>

View File

@ -22,10 +22,7 @@
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
</ItemGroup>
<ItemGroup>
@ -42,7 +39,7 @@
</ItemGroup>
<ItemGroup>
<MvcShim Condition="$(TargetFramework) != ''" Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X\bin\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.deps.json" />
<MvcShim Condition="$(TargetFramework) != ''" Include="$(ArtifactsBinDir)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.deps.json" />
</ItemGroup>
<Target Name="CopyDepsFromShims" AfterTargets="Build">

View File

@ -4,6 +4,7 @@
<Description>ASP.NET Core design time hosting infrastructure for the Razor view engine.</Description>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageTags>$(PackageTags);aspnetcoremvc</PackageTags>
<IsShipping>false</IsShipping>
</PropertyGroup>
<ItemGroup>

View File

@ -22,10 +22,7 @@
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
</ItemGroup>
<ItemGroup>
@ -44,7 +41,7 @@
<Target Name="CopyDepsFromShims" AfterTargets="Build">
<ItemGroup>
<MvcShim Condition="$(TargetFramework) != ''" Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X\bin\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.deps.json" />
<MvcShim Condition="$(TargetFramework) != ''" Include="$(ArtifactsBinDir)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.deps.json" />
</ItemGroup>
<Copy SourceFiles="@(MvcShim)" DestinationFolder="$(OutputPath)" />

View File

@ -22,10 +22,7 @@
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
</ItemGroup>
<ItemGroup>
@ -43,7 +40,7 @@
<Target Name="CopyDepsFromShims" AfterTargets="Build">
<ItemGroup>
<MvcShim Condition="$(TargetFramework) != ''" Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim\bin\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.deps.json" />
<MvcShim Condition="$(TargetFramework) != ''" Include="$(ArtifactsBinDir)\Microsoft.AspNetCore.Razor.Test.MvcShim\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.deps.json" />
</ItemGroup>
<Copy SourceFiles="@(MvcShim)" DestinationFolder="$(OutputPath)" />

View File

@ -11,7 +11,7 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("RazorDeveloperTools, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

View File

@ -9,6 +9,7 @@
<!-- This is not a package, it is part of Razor SDK. -->
<IsPackable>false</IsPackable>
<IsShipping>false</IsShipping>
<EnableApiCheck>false</EnableApiCheck>
<!-- Don't produce rzc.exe -->

View File

@ -12,10 +12,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -13,5 +13,5 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Editor.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.RazorExtension, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("RazorDeveloperTools, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]

View File

@ -22,10 +22,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
</ItemGroup>
</Project>

View File

@ -6,8 +6,11 @@
<TargetName>Microsoft.NET.Sdk.Razor.Tasks</TargetName>
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
<Serviceable>true</Serviceable>
<SdkOutputPath>bin\$(Configuration)\sdk-output\</SdkOutputPath>
<!-- Do not disable ApiCheck. We need to be aware of when we make changes to the Tasks sicne they need to be backwards compatible. -->
<SdkOutputPath>$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\sdk-output\</SdkOutputPath>
<!-- Do not disable ApiCheck. We need to be aware of when we make changes to the Tasks since they need to be backwards compatible. -->
<!-- Allow assemblies outside of lib in the package -->
<NoWarn>$(NoWarn);NU5100</NoWarn>
</PropertyGroup>
<ItemGroup>
@ -38,18 +41,18 @@
<!-- Layout tasks, compiler, and extensions in the sdk-output folder. The entire folder structure gets packaged as-is into the SDK -->
<MSBuild
Projects="..\Microsoft.AspNetCore.Razor.Tools\Microsoft.AspNetCore.Razor.Tools.csproj"
Properties="PublishDir=$(MSBuildProjectDirectory)\$(SdkOutputPath)tools\netcoreapp3.0;TargetFramework=netcoreapp3.0"
Properties="PublishDir=$(SdkOutputPath)tools\netcoreapp3.0;TargetFramework=netcoreapp3.0"
Targets="Publish" />
<ItemGroup>
<MvcRazorExtenionOutput Include="..\Microsoft.AspNetCore.Mvc.Razor.Extensions\bin\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" />
<MvcRazorExtenionOutput Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" />
</ItemGroup>
<Copy SourceFiles="@(MvcRazorExtenionOutput)" DestinationFolder="$(SdkOutputPath)extensions\mvc-3-0\" />
<ItemGroup>
<ProjectOutput Include="..\Microsoft.NET.Sdk.Razor\bin\$(Configuration)\net46*\Microsoft.NET.Sdk.Razor.Tasks.*" />
<ProjectOutput Include="..\Microsoft.NET.Sdk.Razor\bin\$(Configuration)\netstandard2.0*\Microsoft.NET.Sdk.Razor.Tasks.*" />
<ProjectOutput Include="$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\net46*\Microsoft.NET.Sdk.Razor.Tasks.*" />
<ProjectOutput Include="$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\netstandard2.0*\Microsoft.NET.Sdk.Razor.Tasks.*" />
</ItemGroup>
<Copy SourceFiles="@(ProjectOutput)" DestinationFiles="$(SdkOutputPath)tasks\%(RecursiveDir)%(FileName)%(Extension)" />
@ -70,7 +73,7 @@
<ExcludePackageFileFromSigning Include="$(SdkOutputPath)tools\netcoreapp3.0\runtimes\win\lib\netstandard1.3\System.Text.Encoding.CodePages.dll" />
</ItemGroup>
<Target Name="PopulateNuspec" BeforeTargets="GenerateNuspec" DependsOnTargets="LayoutDependencies">
<Target Name="PopulateNuspec" AfterTargets="InitializeStandardNuspecProperties" DependsOnTargets="LayoutDependencies">
<PropertyGroup>
<!-- Make sure we create a symbols.nupkg -->

View File

@ -1,15 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
{
internal static partial class BuildVariables
{
static partial void InitializeVariables()
{
_msBuildPath = @"${MSBuildLocation}";
_microsoftNETCoreApp30PackageVersion = "${MicrosoftNETCoreApp30PackageVersion}";
_netStandardLibrary20PackageVersion = "${NETStandardLibrary20PackageVersion}";
}
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
@ -150,7 +151,8 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
// when we don't explicitly specify a pipe name.
// Publish rzc tool to a temporary path. This is the location based on which the pipe name is generated.
var solutionRoot = TestPathUtilities.GetSolutionRootDirectory("Razor");
var repositoryRoot = ProjectDirectory.SearchUp(AppContext.BaseDirectory, "global.json");
var solutionRoot = Path.Combine(repositoryRoot, "src", "Razor");
var toolAssemblyDirectory = Path.Combine(solutionRoot, "src", "Microsoft.AspNetCore.Razor.Tools");
var toolAssemblyPath = Path.Combine(toolAssemblyDirectory, "Microsoft.AspNetCore.Razor.Tools.csproj");
var projectDirectory = new TestProjectDirectory(solutionRoot, toolAssemblyDirectory, toolAssemblyPath);

View File

@ -30,12 +30,13 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
throw new InvalidOperationException($"{destinationPath} should be empty");
}
var solutionRoot = TestPathUtilities.GetSolutionRootDirectory("Razor");
if (solutionRoot == null)
var repositoryRoot = SearchUp(AppContext.BaseDirectory, "global.json");
if (repositoryRoot == null)
{
throw new InvalidOperationException("Could not find solution root.");
throw new InvalidOperationException("Could not find repository root.");
}
var solutionRoot = Path.Combine(repositoryRoot, "src", "Razor");
var binariesRoot = Path.GetDirectoryName(typeof(ProjectDirectory).Assembly.Location);
foreach (var project in new string[] { originalProjectName, }.Concat(additionalProjects))
@ -72,7 +73,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
var newProjectFilePath = Path.Combine(directoryPath, targetProjectName + extension);
File.Move(oldProjectFilePath, newProjectFilePath);
CopyGlobalJson(solutionRoot, destinationPath);
CopyGlobalJson(repositoryRoot, destinationPath);
return new ProjectDirectory(
destinationPath,
@ -126,9 +127,9 @@ $@"<Project>
});
}
void CopyGlobalJson(string solutionRoot, string projectRoot)
void CopyGlobalJson(string repositoryRoot, string projectRoot)
{
var srcGlobalJson = Path.Combine(solutionRoot, "global.json");
var srcGlobalJson = Path.Combine(repositoryRoot, "global.json");
if (!File.Exists(srcGlobalJson))
{
throw new InvalidOperationException("global.json at the root of the repository could not be found. Run './build /t:Noop' at the repository root and re-run these tests.");
@ -183,5 +184,22 @@ $@"<Project>
}
}
}
public static string SearchUp(string baseDirectory, string fileName)
{
var directoryInfo = new DirectoryInfo(baseDirectory);
do
{
var fileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, fileName));
if (fileInfo.Exists)
{
return fileInfo.DirectoryName;
}
directoryInfo = directoryInfo.Parent;
}
while (directoryInfo.Parent != null);
throw new Exception($"File {fileName} could not be found in {baseDirectory} or its parent directories.");
}
}
}

View File

@ -13,7 +13,6 @@
<!-- Copy references locally so that we can use them in the test. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<BuildVariablesGeneratedFile>$(MSBuildProjectDirectory)\obj\BuildVariables.generated.cs</BuildVariablesGeneratedFile>
<CompileDependsOn>EnsureBuildVariablesGeneratedFile;$(CompileDependsOn)</CompileDependsOn>
</PropertyGroup>
<ItemGroup>
@ -22,11 +21,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
</ItemGroup>
<!-- The test projects rely on these binaries being available -->
@ -47,8 +44,57 @@
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj" />
</ItemGroup>
<Target Name="EnsureBuildVariablesGeneratedFile">
<Error Text="BuildVariables.generated.cs was not found. Run .\build /t:Prepare from the root of the repository to generate it." Condition="!Exists('$(BuildVariablesGeneratedFile)')" />
<PropertyGroup>
<MSBuildLocationFileOutput>$(IntermediateOutputPath)BuildVariables.generated.cs</MSBuildLocationFileOutput>
</PropertyGroup>
<Target
Name="GenerateMSBuildLocationFile"
Condition="'$(TargetFramework)'!=''"
AfterTargets="BeforeBuild"
Inputs="$(MSBuildAllProjects)"
Outputs="$(MSBuildLocationFileOutput)">
<Exec
Condition="'$(OS)' == 'Windows_NT'"
Command='"$(NuGetPackageRoot)vswhere\$(VSWhereVersion)\tools\vswhere.exe" -latest -prerelease -property installationPath -requires Microsoft.Component.MSBuild'
ConsoleToMsBuild="true"
StandardErrorImportance="high">
<Output TaskParameter="ConsoleOutput" PropertyName="_VSInstallDir" />
</Exec>
<Error Condition="'$(OS)' == 'Windows_NT' and '$(_VSInstallDir)'==''" Text="Visual Studio not found on Windows." />
<PropertyGroup>
<_DesktopMSBuildPath Condition="'$(OS)' == 'Windows_NT' and Exists('$(_VSInstallDir)\MSBuild\Current\Bin\msbuild.exe')">$(_VSInstallDir)\MSBuild\Current\Bin\msbuild.exe</_DesktopMSBuildPath>
<_DesktopMSBuildPath Condition="'$(OS)' == 'Windows_NT' and Exists('$(_VSInstallDir)\MSBuild\15.0\Bin\msbuild.exe')">$(_VSInstallDir)\MSBuild\15.0\Bin\msbuild.exe</_DesktopMSBuildPath>
<_Content><![CDATA[
namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
{
internal static partial class BuildVariables
{
static partial void InitializeVariables()
{
_msBuildPath = @"$(_DesktopMSBuildPath)";
_microsoftNETCoreApp30PackageVersion = "$(MicrosoftNETCoreApp30PackageVersion)";
_netStandardLibrary20PackageVersion = "$(NETStandardLibrary20PackageVersion)";
}
}
}
]]>
</_Content>
</PropertyGroup>
<Error Condition="'$(OS)' == 'Windows_NT' and '$(_DesktopMSBuildPath)'==''" Text="MSBuild.exe not found on Windows." />
<MakeDir Directories="$(IntermediateOutputPath)" />
<WriteLinesToFile Lines="$([MSBuild]::Escape($(_Content)))" File="$(MSBuildLocationFileOutput)" Overwrite="True" WriteOnlyWhenDifferent="True" />
<ItemGroup>
<Compile Include="$(MSBuildLocationFileOutput)">
<Visible>false</Visible>
</Compile>
<FileWrites Include="$(MSBuildLocationFileOutput)" />
</ItemGroup>
</Target>
</Project>

View File

@ -3,7 +3,6 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Testing;
namespace Microsoft.AspNetCore.Razor.Language
{
@ -11,18 +10,32 @@ namespace Microsoft.AspNetCore.Razor.Language
{
public static string GetProjectDirectory(Type type)
{
var solutionDir = TestPathUtilities.GetSolutionRootDirectory("Razor");
var repoRoot = SearchUp(AppContext.BaseDirectory, "global.json");
var assemblyName = type.Assembly.GetName().Name;
var projectDirectory = Path.Combine(solutionDir, "test", assemblyName);
var projectDirectory = Path.Combine(repoRoot, "src", "Razor", "test", assemblyName);
if (!Directory.Exists(projectDirectory))
{
throw new InvalidOperationException(
$@"Could not locate project directory for type {type.FullName}.
Directory probe path: {projectDirectory}.");
throw new InvalidOperationException($@"Could not locate project directory for type {type.FullName}. Directory probe path: {projectDirectory}.");
}
return projectDirectory;
}
private static string SearchUp(string baseDirectory, string fileName)
{
var directoryInfo = new DirectoryInfo(baseDirectory);
do
{
var fileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, fileName));
if (fileInfo.Exists)
{
return fileInfo.DirectoryName;
}
directoryInfo = directoryInfo.Parent;
}
while (directoryInfo.Parent != null);
throw new Exception($"File {fileName} could not be found in {baseDirectory} or its parent directories.");
}
}
}

View File

@ -23,13 +23,35 @@ namespace Microsoft.CodeAnalysis
var dependencyContext = DependencyContext.Load(assembly);
var metadataReferences = dependencyContext.CompileLibraries
.SelectMany(l => l.ResolveReferencePaths())
.SelectMany(l => ResolvePaths(l))
.Select(assemblyPath => MetadataReference.CreateFromFile(assemblyPath))
.ToArray();
return metadataReferences;
}
private static IEnumerable<string> ResolvePaths(CompilationLibrary library)
{
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (var i = 0; i < assemblies.Length; i++)
{
if (assemblies[i].GetName().Name == library.Name)
{
return new[] { assemblies[i].Location };
}
}
try
{
return library.ResolveReferencePaths();
}
catch (InvalidOperationException)
{
}
return Array.Empty<string>();
}
public static string AssemblyName => "TestAssembly";
public static CSharpCompilation Create(Assembly assembly, SyntaxTree syntaxTree = null)

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<RazorSdkDirectoryRoot>$(RazorSdkProjectDirectory)bin\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
<PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<RazorSdkDirectoryRoot>$(RazorSdkProjectDirectory)bin\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
<PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<RazorSdkDirectoryRoot>$(RazorSdkProjectDirectory)bin\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
<PropertyGroup>

View File

@ -6,10 +6,10 @@
<SolutionRoot>$([MSBuild]::EnsureTrailingSlash('$(SolutionRoot)'))</SolutionRoot>
<!-- Retarget tests to use the copy of the Sdk from source -->
<RazorSdkProjectDirectory>$(SolutionRoot)src\Microsoft.NET.Sdk.Razor\</RazorSdkProjectDirectory>
<RazorSdkArtifactsDirectory>$(SolutionRoot)..\..\artifacts\bin\Microsoft.NET.Sdk.Razor\</RazorSdkArtifactsDirectory>
<RazorSdkCurrentVersionProps>$(RazorSdkProjectDirectory)build\netstandard2.0\Sdk.Razor.CurrentVersion.props</RazorSdkCurrentVersionProps>
<RazorSdkCurrentVersionTargets>$(RazorSdkProjectDirectory)build\netstandard2.0\Sdk.Razor.CurrentVersion.targets</RazorSdkCurrentVersionTargets>
<RazorSdkCurrentVersionProps>$(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.props</RazorSdkCurrentVersionProps>
<RazorSdkCurrentVersionTargets>$(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets</RazorSdkCurrentVersionTargets>
</PropertyGroup>
<!-- Import solution dependencies.props when building in place -->

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<RazorSdkDirectoryRoot>$(RazorSdkProjectDirectory)bin\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
<PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<RazorSdkDirectoryRoot>$(RazorSdkProjectDirectory)bin\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
<PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<RazorSdkDirectoryRoot>$(RazorSdkProjectDirectory)bin\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
<PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<RazorSdkDirectoryRoot>$(RazorSdkProjectDirectory)bin\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
<PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<RazorSdkDirectoryRoot>$(RazorSdkProjectDirectory)bin\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
<RazorSdkDirectoryRoot>$(RazorSdkArtifactsDirectory)$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
</PropertyGroup>
<PropertyGroup>