Razor SDK build ordering issues (#22684)

* Razor SDK build ordering issues

* Build the SDK completely regardless of the MSBuild runtime type
* Split SDK integration tests into a separate project. Clean up project file

* Add project to sln

* Update Microsoft.NET.Sdk.Razor.csproj

* Fixup tests

* Avoid rebuilding dependencies if they appear up to date. Fixup tests

* Fixup

* Update CSharp.Common.props

* Cleanup the build
This commit is contained in:
Pranav K 2020-06-11 14:16:05 -07:00 committed by GitHub
parent 5d996207d5
commit 0a42cca945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 174 additions and 143 deletions

View File

@ -22,11 +22,12 @@
several versions older than latest. We reference the project to ensure it's built before the other projects that use it. Since this several versions older than latest. We reference the project to ensure it's built before the other projects that use it. Since this
is a project reference, we must explicitly import the props file and also specify the output location of the SDK directory. is a project reference, we must explicitly import the props file and also specify the output location of the SDK directory.
--> -->
<ProjectReference Include="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\Microsoft.NET.Sdk.Razor.csproj" PrivateAssets="All" IsImplicitlyDefined="true" ReferenceOutputAssembly="false" > <ProjectReference Include="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\Microsoft.NET.Sdk.Razor.csproj"
<!-- Use the same logic as Sdk.Razor.CurrentVersion.Targets --> PrivateAssets="All"
<SetTargetFramework Condition=" '$(MSBuildRuntimeType)' == 'Core'">TargetFramework=$(DefaultNetCoreTargetFramework)</SetTargetFramework> IsImplicitlyDefined="true"
<SetTargetFramework Condition=" '$(MSBuildRuntimeType)' != 'Core'">TargetFramework=net46</SetTargetFramework> ReferenceOutputAssembly="false"
</ProjectReference> SkipGetTargetFrameworkProperties="true"
UndefineProperties="TargetFramework;TargetFrameworks" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,6 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Razor.IntegrationTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]

View File

@ -6,7 +6,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Testing; using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyModel; using Microsoft.Extensions.DependencyModel;
using Xunit; using Xunit;
@ -632,7 +631,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.BuildFailed(result); Assert.BuildFailed(result);
Assert.BuildOutputContainsLine( Assert.BuildOutputContainsLine(
result, result,
$"Invalid option 5.0 for Razor language version --version; must be Latest or a valid version in range {RazorLanguageVersion.Version_1_0} to {RazorLanguageVersion.Latest}."); $"Invalid option 5.0 for Razor language version --version; must be Latest or a valid version in range 1.0 to 3.0.");
// Compilation failed without creating the views assembly // Compilation failed without creating the views assembly
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");

View File

@ -5,7 +5,6 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Testing; using Microsoft.AspNetCore.Testing;
using Xunit; using Xunit;
@ -108,7 +107,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.BuildFailed(result); Assert.BuildFailed(result);
Assert.BuildOutputContainsLine( Assert.BuildOutputContainsLine(
result, result,
$"Invalid option 5.0 for Razor language version --version; must be Latest or a valid version in range {RazorLanguageVersion.Version_1_0} to {RazorLanguageVersion.Latest}."); $"Invalid option 5.0 for Razor language version --version; must be Latest or a valid version in range 1.0 to 3.0.");
// Compilation failed without creating the views assembly // Compilation failed without creating the views assembly
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");

View File

@ -0,0 +1,106 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!--
There's not much value in multi-targeting here, this doesn't run much .NET code, it tests MSBuild.
This is also a partial workaround for https://github.com/Microsoft/msbuild/issues/2661 - this project
has netcoreapp dependencies that need to be built first.
-->
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<DefineConstants Condition="'$(PreserveWorkingDirectory)'=='true'">$(DefineConstants);PRESERVE_WORKING_DIRECTORY</DefineConstants>
<!-- Tests do not work on Helix yet -->
<BuildHelixPayload>false</BuildHelixPayload>
</PropertyGroup>
<ItemGroup>
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Build.Utilities.Core" />
<Reference Include="Microsoft.Extensions.DependencyModel" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>Testing.AdditionalRestoreSources</_Parameter1>
<_Parameter2>$(MSBuildThisFileDirectory)..\testassets\PregeneratedPackages</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ArtifactsLogDir</_Parameter1>
<_Parameter2>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'log', '$(_BuildConfig)'))</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ProcDumpToolPath</_Parameter1>
<_Parameter2>$(ProcDumpPath)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>Testing.RepoRoot</_Parameter1>
<_Parameter2>$(RepoRoot)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>MicrosoftNETCoreAppRuntimeVersion</_Parameter1>
<_Parameter2>$(MicrosoftNETCoreAppRuntimeVersion)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>MicrosoftNetCompilersToolsetPackageVersion</_Parameter1>
<_Parameter2>$(MicrosoftNetCompilersToolsetPackageVersion)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>RazorSdkDirectoryRoot</_Parameter1>
<_Parameter2>$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\sdk-output\</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<Reference Include="rzc" />
<ProjectReference Include="..\..\test\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj" />
<ProjectReference Include="..\src\Microsoft.NET.Sdk.Razor.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemGroup>
<Target Name="GenerateTestData" BeforeTargets="GetAssemblyAttributes">
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="&quot;$(NuGetPackageRoot)vswhere\$(VSWhereVersion)\tools\vswhere.exe&quot; -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)'=='' and '$(Test)' == 'true'" 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>
</PropertyGroup>
<Error Condition="'$(OS)' == 'Windows_NT' and '$(_DesktopMSBuildPath)'=='' and '$(Test)' == 'true'" Text="MSBuild.exe not found on Windows." />
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>DesktopMSBuildPath</_Parameter1>
<_Parameter2>$(_DesktopMSBuildPath)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>
<Target Name="RestoreTestProjects" BeforeTargets="Restore;Build" Condition="'$(DotNetBuildFromSource)' != 'true'">
<MSBuild Projects="..\..\test\testassets\RestoreTestProjects\RestoreTestProjects.csproj" Targets="Restore" Properties="MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);RepoRoot=$(RepoRoot)" />
<MSBuild Projects="..\..\test\testassets\PackageLibraryDirectDependency\PackageLibraryDirectDependency.csproj" Targets="Restore" Properties="MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);RepoRoot=$(RepoRoot)" />
<MSBuild Projects="..\..\test\testassets\PackageLibraryTransitiveDependency\PackageLibraryTransitiveDependency.csproj" Targets="Restore" Properties="MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);RepoRoot=$(RepoRoot)" />
</Target>
<Target Name="EnsureLogFolder" AfterTargets="Build">
<MakeDir Directories="$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'log', '$(_BuildConfig)'))" />
</Target>
</Project>

View File

@ -0,0 +1,5 @@
{
"methodDisplay": "method",
"shadowCopy": false,
"maxParallelThreads": -1
}

View File

@ -26,8 +26,22 @@
<Reference Include="Microsoft.Build.Utilities.Core" /> <Reference Include="Microsoft.Build.Utilities.Core" />
<Reference Include="System.Reflection.Metadata" Condition="'$(TargetFramework)'=='net46'" /> <Reference Include="System.Reflection.Metadata" Condition="'$(TargetFramework)'=='net46'" />
<Reference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" ReferenceOutputAssembly="false" Condition="'$(TargetFramework)'=='$(DefaultNetCoreTargetFramework)'" /> <ProjectReference
<Reference Include="rzc" ReferenceOutputAssembly="false" Condition="'$(TargetFramework)'=='$(DefaultNetCoreTargetFramework)'" /> Include="..\..\Microsoft.AspNetCore.Razor.Tools\src\Microsoft.AspNetCore.Razor.Tools.csproj"
Targets="Publish"
ReferenceOutputAssembly="false"
IsImplicityDefined="false"
SkipGetTargetFrameworkProperties="true"
UndefineProperties="TargetFramework;TargetFrameworks" />
<ProjectReference
Include="..\..\Microsoft.AspNetCore.Mvc.Razor.Extensions\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj"
Targets="Publish"
ReferenceOutputAssembly="false"
IsImplicityDefined="false"
SkipGetTargetFrameworkProperties="true"
UndefineProperties="TargetFramework;TargetFrameworks" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -48,35 +62,33 @@
<Content Include="_._" CopyToOutputDirectory="PreserveNewest" /> <Content Include="_._" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup> </ItemGroup>
<Target Name="LayoutDependencies" BeforeTargets="Build"> <Target Name="LayoutDependencies" BeforeTargets="Build"
Condition="'$(IsInnerBuild)' != 'true' AND '$(NoBuild)' != 'true'">
<!-- Layout tasks, compiler, and extensions in the sdk-output folder. The entire folder structure gets packaged as-is into the SDK --> <!-- 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\src\Microsoft.AspNetCore.Razor.Tools.csproj"
Properties="PublishDir=$(SdkOutputPath)temp;TargetFramework=netcoreapp3.0"
Targets="Publish"
ContinueOnError="true" />
<MSBuild
Projects="..\..\Microsoft.AspNetCore.Mvc.Razor.Extensions\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj"
Properties="TargetFramework=netstandard2.0"
Targets="Build"
Condition="'$(NoBuild)' != 'true'"
ContinueOnError="true" />
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'"> <PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
<_ContinueOnError>true</_ContinueOnError> <_ContinueOnError>true</_ContinueOnError>
<_Retries>1</_Retries> <_Retries>1</_Retries>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'"> <PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<_ContinueOnError>false</_ContinueOnError> <_ContinueOnError>false</_ContinueOnError>
<_Retries>10</_Retries> <_Retries>10</_Retries>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<RazorToolsOutput Include="$(SdkOutputPath)temp\**\*.*" /> <RazorToolsOutput Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Razor.Tools\$(Configuration)\netcoreapp3.0\publish\**\*.*" />
<MvcRazorExtensionOutput Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" /> <MvcRazorExtensionOutput Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions\$(Configuration)\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" />
</ItemGroup> </ItemGroup>
<Error
Message="rzc outputs were not found in $(ArtifactsBinDir)Microsoft.AspNetCore.Razor.Tools\$(Configuration)\netcoreapp3.0\publish"
Condition="'@(RazorToolsOutput->Count())' == '0'" />
<Error
Message="Mvc extensions outputs were not found in $(ArtifactsBinDir)Microsoft.AspNetCore.Mvc.Razor.Extensions\$(Configuration)\netstandard2.0"
Condition="'@(MvcRazorExtensionOutput->Count())' == '0'" />
<Copy SourceFiles="@(RazorToolsOutput)" DestinationFolder="$(SdkOutputPath)tools\netcoreapp3.0\" SkipUnchangedFiles="true" Retries="$(_Retries)" ContinueOnError="$(_ContinueOnError)" /> <Copy SourceFiles="@(RazorToolsOutput)" DestinationFolder="$(SdkOutputPath)tools\netcoreapp3.0\" SkipUnchangedFiles="true" Retries="$(_Retries)" ContinueOnError="$(_ContinueOnError)" />
<Copy SourceFiles="@(MvcRazorExtensionOutput)" DestinationFolder="$(SdkOutputPath)extensions\mvc-3-0\" SkipUnchangedFiles="true" Retries="$(_Retries)" ContinueOnError="$(_ContinueOnError)"> <Copy SourceFiles="@(MvcRazorExtensionOutput)" DestinationFolder="$(SdkOutputPath)extensions\mvc-3-0\" SkipUnchangedFiles="true" Retries="$(_Retries)" ContinueOnError="$(_ContinueOnError)">
<Output TaskParameter="CopiedFiles" ItemName="FileWrites" /> <Output TaskParameter="CopiedFiles" ItemName="FileWrites" />
@ -94,13 +106,11 @@
<Output TaskParameter="CopiedFiles" ItemName="FileWrites" /> <Output TaskParameter="CopiedFiles" ItemName="FileWrites" />
</Copy> </Copy>
<Message Importance="High" Text="Prepared Razor SDK at $(SdkOutputPath)" /> <ItemGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<ItemGroup>
<_PreparedRazorSdkFiles Include="$(SdkOutputPath)**\*.*" /> <_PreparedRazorSdkFiles Include="$(SdkOutputPath)**\*.*" />
</ItemGroup> </ItemGroup>
<Message Importance="High" Text="Prepared Razor SDK at $(SdkOutputPath)" Condition="'$(ContinuousIntegrationBuild)' == 'true'" />
<Message Importance="High" Text="Prepared files:@(_PreparedRazorSdkFiles->'%0a%(Identity)')" /> <Message Importance="High" Text="Prepared files:@(_PreparedRazorSdkFiles->'%0a%(Identity)')" Condition="'$(ContinuousIntegrationBuild)' == 'true'" />
</Target> </Target>
<Target Name="PopulateNuspec" BeforeTargets="InitializeStandardNuspecProperties" DependsOnTargets="LayoutDependencies"> <Target Name="PopulateNuspec" BeforeTargets="InitializeStandardNuspecProperties" DependsOnTargets="LayoutDependencies">
@ -112,4 +122,9 @@
<NuspecProperty Include="outputPath=$(OutputPath)\sdk-output" /> <NuspecProperty Include="outputPath=$(OutputPath)\sdk-output" />
</ItemGroup> </ItemGroup>
</Target> </Target>
<!-- Workarounds to allow publishing to work when the RazorSDK is referenced as a project. -->
<Target Name="GetTargetPath" />
<Target Name="GetCopyToPublishDirectoryItems" />
</Project> </Project>

View File

@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.Razor.Tasks
// Assert // Assert
Assert.True(result); Assert.True(result);
var document = File.ReadAllText(file); var document = File.ReadAllText(file);
Assert.Equal(expectedDocument, document); Assert.Equal(expectedDocument, document, ignoreLineEndingDifferences: true);
} }
finally finally
{ {
@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.Razor.Tasks
// Assert // Assert
Assert.True(result); Assert.True(result);
var document = File.ReadAllText(file); var document = File.ReadAllText(file);
Assert.Equal(expectedDocument, document); Assert.Equal(expectedDocument, document, ignoreLineEndingDifferences: true);
} }
finally finally
{ {
@ -328,7 +328,7 @@ namespace Microsoft.AspNetCore.Razor.Tasks
// Assert // Assert
Assert.True(result); Assert.True(result);
var document = File.ReadAllText(file); var document = File.ReadAllText(file);
Assert.Equal(expectedDocument, document); Assert.Equal(expectedDocument, document, ignoreLineEndingDifferences: true);
} }
finally finally
{ {

View File

@ -406,7 +406,7 @@ namespace Microsoft.AspNetCore.Razor.Tasks
// Assert // Assert
Assert.True(result); Assert.True(result);
var document = File.ReadAllText(file); var document = File.ReadAllText(file);
Assert.Equal(expectedDocument, document); Assert.Equal(expectedDocument, document, ignoreLineEndingDifferences: true);
} }
finally finally
{ {

View File

@ -1,117 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<!--
There's not much value in multi-targeting here, this doesn't run much .NET code, it tests MSBuild.
This is also a partial workaround for https://github.com/Microsoft/msbuild/issues/2661 - this project
has netcoreapp dependencies that need to be built first.
-->
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<DefineConstants Condition="'$(PreserveWorkingDirectory)'=='true'">$(DefineConstants);PRESERVE_WORKING_DIRECTORY</DefineConstants>
<!-- Copy references locally so that we can use them in the test. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<BuildVariablesGeneratedFile>$(MSBuildProjectDirectory)\obj\BuildVariables.generated.cs</BuildVariablesGeneratedFile>
<!-- Tests do not work on Helix yet -->
<BuildHelixPayload>false</BuildHelixPayload>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" /> <None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
<Compile Include="$(BuildVariablesGeneratedFile)" Condition="Exists('$(BuildVariablesGeneratedFile)')" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Build.Utilities.Core" /> <Reference Include="Microsoft.Build.Utilities.Core" />
<Reference Include="Microsoft.Extensions.DependencyModel" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>Testing.AdditionalRestoreSources</_Parameter1>
<_Parameter2>$(MSBuildThisFileDirectory)..\testassets\PregeneratedPackages</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ArtifactsLogDir</_Parameter1>
<_Parameter2>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'log', '$(_BuildConfig)'))</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>ProcDumpToolPath</_Parameter1>
<_Parameter2>$(ProcDumpPath)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>Testing.RepoRoot</_Parameter1>
<_Parameter2>$(RepoRoot)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>MicrosoftNETCoreAppRuntimeVersion</_Parameter1>
<_Parameter2>$(MicrosoftNETCoreAppRuntimeVersion)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>MicrosoftNetCompilersToolsetPackageVersion</_Parameter1>
<_Parameter2>$(MicrosoftNetCompilersToolsetPackageVersion)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>RazorSdkDirectoryRoot</_Parameter1>
<_Parameter2>$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\sdk-output\</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<!-- The test projects rely on these binaries being available -->
<Reference Include="System.Diagnostics.DiagnosticSource" />
<Reference Include="rzc" />
<Reference Include="Microsoft.NET.Sdk.Razor" /> <Reference Include="Microsoft.NET.Sdk.Razor" />
<ProjectReference Include="..\..\test\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj" />
<!-- We don't need anything in this assembly, we just want to make sure it's built -->
<ProjectReference Include="..\..\Microsoft.AspNetCore.Mvc.Razor.Extensions\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj" ReferenceOutputAssembly="false" >
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
</ProjectReference>
</ItemGroup> </ItemGroup>
<PropertyGroup>
<MSBuildLocationFileOutput>$(IntermediateOutputPath)BuildVariables.generated.cs</MSBuildLocationFileOutput>
</PropertyGroup>
<Target Name="GenerateTestData" BeforeTargets="GetAssemblyAttributes">
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="&quot;$(NuGetPackageRoot)vswhere\$(VSWhereVersion)\tools\vswhere.exe&quot; -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)'=='' and '$(Test)' == 'true'" 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>
</PropertyGroup>
<Error Condition="'$(OS)' == 'Windows_NT' and '$(_DesktopMSBuildPath)'=='' and '$(Test)' == 'true'" Text="MSBuild.exe not found on Windows." />
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>DesktopMSBuildPath</_Parameter1>
<_Parameter2>$(_DesktopMSBuildPath)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>
<Target Name="RestoreTestProjects" BeforeTargets="Restore;Build" Condition="'$(DotNetBuildFromSource)' != 'true'">
<MSBuild Projects="..\..\test\testassets\RestoreTestProjects\RestoreTestProjects.csproj" Targets="Restore" Properties="MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);RepoRoot=$(RepoRoot)" />
<MSBuild Projects="..\..\test\testassets\PackageLibraryDirectDependency\PackageLibraryDirectDependency.csproj" Targets="Restore" Properties="MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);RepoRoot=$(RepoRoot)" />
<MSBuild Projects="..\..\test\testassets\PackageLibraryTransitiveDependency\PackageLibraryTransitiveDependency.csproj" Targets="Restore" Properties="MicrosoftNetCompilersToolsetPackageVersion=$(MicrosoftNetCompilersToolsetPackageVersion);RepoRoot=$(RepoRoot)" />
</Target>
<Target Name="EnsureLogFolder" AfterTargets="Build">
<MakeDir Directories="$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'log', '$(_BuildConfig)'))" />
</Target>
</Project> </Project>

View File

@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Razor.Tasks
// Assert // Assert
Assert.True(result); Assert.True(result);
var document = File.ReadAllText(file); var document = File.ReadAllText(file);
Assert.Equal(expectedDocument, document); Assert.Equal(expectedDocument, document, ignoreLineEndingDifferences: true);
} }
finally finally
{ {

View File

@ -86,6 +86,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X", "test\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.csproj", "{B3A97984-FC0A-4FBE-93D4-6CA7049252DC}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X", "test\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X\Microsoft.AspNetCore.Razor.Test.MvcShim.Version2_X.csproj", "{B3A97984-FC0A-4FBE-93D4-6CA7049252DC}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.Razor.IntegrationTests", "Microsoft.NET.Sdk.Razor\integrationtests\Microsoft.NET.Sdk.Razor.IntegrationTests.csproj", "{4EA6AAC9-F49B-4933-8009-D1F94B75DEB0}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -200,6 +202,10 @@ Global
{B3A97984-FC0A-4FBE-93D4-6CA7049252DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {B3A97984-FC0A-4FBE-93D4-6CA7049252DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3A97984-FC0A-4FBE-93D4-6CA7049252DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {B3A97984-FC0A-4FBE-93D4-6CA7049252DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3A97984-FC0A-4FBE-93D4-6CA7049252DC}.Release|Any CPU.Build.0 = Release|Any CPU {B3A97984-FC0A-4FBE-93D4-6CA7049252DC}.Release|Any CPU.Build.0 = Release|Any CPU
{4EA6AAC9-F49B-4933-8009-D1F94B75DEB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4EA6AAC9-F49B-4933-8009-D1F94B75DEB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EA6AAC9-F49B-4933-8009-D1F94B75DEB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EA6AAC9-F49B-4933-8009-D1F94B75DEB0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -232,6 +238,7 @@ Global
{C6CAD507-F441-4FA8-AE95-99086B5A245F} = {CFF4CF22-6CCF-41E6-8041-E3CC26ED27BA} {C6CAD507-F441-4FA8-AE95-99086B5A245F} = {CFF4CF22-6CCF-41E6-8041-E3CC26ED27BA}
{381824E8-40CE-475C-9035-9F36AD34EBB7} = {CFF4CF22-6CCF-41E6-8041-E3CC26ED27BA} {381824E8-40CE-475C-9035-9F36AD34EBB7} = {CFF4CF22-6CCF-41E6-8041-E3CC26ED27BA}
{B3A97984-FC0A-4FBE-93D4-6CA7049252DC} = {CFF4CF22-6CCF-41E6-8041-E3CC26ED27BA} {B3A97984-FC0A-4FBE-93D4-6CA7049252DC} = {CFF4CF22-6CCF-41E6-8041-E3CC26ED27BA}
{4EA6AAC9-F49B-4933-8009-D1F94B75DEB0} = {433DDF1D-F86A-492E-B448-4F299F56FACA}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {779069AC-1F9F-407F-92C7-28507D91D64E} SolutionGuid = {779069AC-1F9F-407F-92C7-28507D91D64E}