Consolidate RazorSdkDirectory logic (#22836)
* Consolidate RazorSdkDirectory logic
This commit is contained in:
parent
a2162e565f
commit
11c8ad4010
|
|
@ -14,30 +14,24 @@
|
|||
<PackageReference Condition="'$(DotNetBuildFromSource)' != 'true'" Include="Microsoft.DotNet.GenAPI" PrivateAssets="All" Version="$(MicrosoftDotNetGenApiPackageVersion)" IsImplicitlyDefined="true" />
|
||||
</ItemGroup>
|
||||
|
||||
<Choose>
|
||||
<When Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
|
||||
<ItemGroup>
|
||||
<!--
|
||||
Use the Razor SDK as a project reference. The version of the .NET Core SDK we build with often contains a version of the Razor SDK
|
||||
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.
|
||||
-->
|
||||
<ProjectReference Include="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\Microsoft.NET.Sdk.Razor.csproj"
|
||||
PrivateAssets="All"
|
||||
IsImplicitlyDefined="true"
|
||||
ReferenceOutputAssembly="false"
|
||||
SkipGetTargetFrameworkProperties="true"
|
||||
UndefineProperties="TargetFramework;TargetFrameworks" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<RazorSdkDirectoryRoot>$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
|
||||
<Import Project="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''" />
|
||||
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
|
||||
<!--
|
||||
Use the Razor SDK as a project reference. The version of the .NET Core SDK we build with often contains a version of the Razor SDK
|
||||
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.
|
||||
-->
|
||||
<ProjectReference Include="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\Microsoft.NET.Sdk.Razor.csproj"
|
||||
PrivateAssets="All"
|
||||
IsImplicitlyDefined="true"
|
||||
ReferenceOutputAssembly="false"
|
||||
SkipGetTargetFrameworkProperties="true"
|
||||
UndefineProperties="TargetFramework;TargetFrameworks" />
|
||||
</ItemGroup>
|
||||
|
||||
<ImportGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
|
||||
<Import Project="$(RepoRoot)eng\targets\GetRazorSDKDirectory.props" />
|
||||
<Import Project="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" />
|
||||
</ImportGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(IsTestProject)' == 'true' ">
|
||||
<Reference Include="Microsoft.AspNetCore.Testing" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<RazorSdkDirectoryRoot Condition="'$(RazorSdkDirectoryRoot)' == ''">$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -68,6 +68,10 @@
|
|||
<_Parameter2>$(TargetFramework)</_Parameter2>
|
||||
<_Parameter3></_Parameter3>
|
||||
</AssemblyAttribute>
|
||||
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
|
||||
<_Parameter1>Test.RazorSdkDirectoryRoot</_Parameter1>
|
||||
<_Parameter2>$(RazorSdkDirectoryRoot)</_Parameter2>
|
||||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PrepareForTest" BeforeTargets="GetAssemblyAttributes" Condition="$(DesignTimeBuild) != true">
|
||||
|
|
|
|||
|
|
@ -35,8 +35,4 @@
|
|||
Since this is a project reference, we must explicitly import the props file and also specify the output location of the SDK directory.
|
||||
-->
|
||||
<Import Project="${RepoRoot}src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''" />
|
||||
|
||||
<PropertyGroup>
|
||||
<RazorSdkDirectoryRoot>${ArtifactsBinDir}Microsoft.NET.Sdk.Razor\${Configuration}\sdk-output\</RazorSdkDirectoryRoot>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ namespace Templates.Test.Helpers
|
|||
public string ProjectGuid { get; set; }
|
||||
public string TemplateOutputDir { get; set; }
|
||||
public string TargetFramework { get; set; } = GetAssemblyMetadata("Test.DefaultTargetFramework");
|
||||
public string RazorSdkDirectoryRoot { get; set; } = GetAssemblyMetadata("Test.RazorSdkDirectoryRoot");
|
||||
|
||||
public string TemplateBuildDir => Path.Combine(TemplateOutputDir, "bin", "Debug", TargetFramework);
|
||||
public string TemplatePublishDir => Path.Combine(TemplateOutputDir, "bin", "Release", TargetFramework, "publish");
|
||||
|
|
@ -116,7 +117,9 @@ namespace Templates.Test.Helpers
|
|||
// Avoid restoring as part of build or publish. These projects should have already restored as part of running dotnet new. Explicitly disabling restore
|
||||
// should avoid any global contention and we can execute a build or publish in a lock-free way
|
||||
|
||||
using var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"publish --no-restore -c Release /bl {additionalArgs}", packageOptions);
|
||||
var razorSDKarg = string.IsNullOrEmpty(RazorSdkDirectoryRoot) ? string.Empty : $"/p:RazorSdkDirectoryRoot={RazorSdkDirectoryRoot}";
|
||||
|
||||
using var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"publish --no-restore -c Release /bl {razorSDKarg} {additionalArgs}", packageOptions);
|
||||
await result.Exited;
|
||||
CaptureBinLogOnFailure(result);
|
||||
return new ProcessResult(result);
|
||||
|
|
@ -129,7 +132,9 @@ namespace Templates.Test.Helpers
|
|||
// Avoid restoring as part of build or publish. These projects should have already restored as part of running dotnet new. Explicitly disabling restore
|
||||
// should avoid any global contention and we can execute a build or publish in a lock-free way
|
||||
|
||||
using var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"build --no-restore -c Debug /bl {additionalArgs}", packageOptions);
|
||||
var razorSDKarg = string.IsNullOrEmpty(RazorSdkDirectoryRoot) ? string.Empty : $"/p:RazorSdkDirectoryRoot={RazorSdkDirectoryRoot}";
|
||||
|
||||
using var result = ProcessEx.Run(Output, TemplateOutputDir, DotNetMuxer.MuxerPathOrDefault(), $"build --no-restore -c Debug /bl {razorSDKarg} {additionalArgs}", packageOptions);
|
||||
await result.Exited;
|
||||
CaptureBinLogOnFailure(result);
|
||||
return new ProcessResult(result);
|
||||
|
|
|
|||
|
|
@ -34,9 +34,5 @@
|
|||
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.
|
||||
-->
|
||||
<Import Project="${RepoRoot}src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''" />
|
||||
|
||||
<PropertyGroup>
|
||||
<RazorSdkDirectoryRoot>${ArtifactsBinDir}Microsoft.NET.Sdk.Razor\${Configuration}\sdk-output\</RazorSdkDirectoryRoot>
|
||||
</PropertyGroup>
|
||||
<Import Project="${RepoRoot}src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''" />
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
<!-- Shared testing infrastructure for running E2E tests using selenium -->
|
||||
<Import Project="$(SharedSourceRoot)E2ETesting\E2ETesting.props" />
|
||||
<Import Project="$(RepoRoot)eng\targets\GetRazorSDKDirectory.props" Condition="'$(IsHelixJob)' != 'true'"/>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
|
||||
|
|
@ -61,6 +62,10 @@
|
|||
<_Parameter1>Test.DefaultTargetFramework</_Parameter1>
|
||||
<_Parameter2>$(DefaultNetCoreTargetFramework)</_Parameter2>
|
||||
</AssemblyAttribute>
|
||||
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
|
||||
<_Parameter1>Test.RazorSdkDirectoryRoot</_Parameter1>
|
||||
<_Parameter2>$(RazorSdkDirectoryRoot)</_Parameter2>
|
||||
</AssemblyAttribute>
|
||||
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(ContinuousIntegrationBuild)' == 'true'">
|
||||
<_Parameter1>ContinuousIntegrationBuild</_Parameter1>
|
||||
<_Parameter2>true</_Parameter2>
|
||||
|
|
|
|||
Loading…
Reference in New Issue