Generate application part attributes

* Add support for generating attributes on Razor assembly
* Generate ProvideApplicationPartFactoryAttribute on Razor assembly
* Generate RelatedAssemblyAttribute on application assembly
This commit is contained in:
Pranav K 2018-03-08 10:50:16 -08:00
parent 2f79b90af5
commit 483fba5972
16 changed files with 304 additions and 10 deletions

View File

@ -11,4 +11,16 @@
--> -->
<RazorTargetNameSuffix Condition="'$(RazorTargetNameSuffix)'==''">.Views</RazorTargetNameSuffix> <RazorTargetNameSuffix Condition="'$(RazorTargetNameSuffix)'==''">.Views</RazorTargetNameSuffix>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="'$(GenerateRazorAssemblyInfo)'=='true'">
<AssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute">
<_Parameter1>$(RazorTargetName)</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<RazorAssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute">
<_Parameter1>Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFactory, Microsoft.AspNetCore.Mvc.Razor</_Parameter1>
</RazorAssemblyAttribute>
</ItemGroup>
</Project> </Project>

View File

@ -177,4 +177,5 @@ Copyright (c) .NET Foundation. All rights reserved.
<FileWrites Include="@(_RazorDebugSymbolsIntermediatePath)" Condition="Exists('@(_RazorDebugSymbolsIntermediatePath)')" /> <FileWrites Include="@(_RazorDebugSymbolsIntermediatePath)" Condition="Exists('@(_RazorDebugSymbolsIntermediatePath)')" />
</ItemGroup> </ItemGroup>
</Target> </Target>
</Project> </Project>

View File

@ -0,0 +1,120 @@
<!--
***********************************************************************************************
Microsoft.NET.Sdk.Razor.GenerateAssemblyInfo.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project ToolsVersion="14.0">
<PropertyGroup>
<!-- Determines if the generated Razor assembly includes an auto-generated assembly info. -->
<GenerateRazorTargetAssemblyInfo Condition="'$(GenerateRazorTargetAssemblyInfo)'==''">$(GenerateAssemblyInfo)</GenerateRazorTargetAssemblyInfo>
<GenerateRazorTargetAssemblyInfo Condition="'$(GenerateRazorTargetAssemblyInfo)'==''">true</GenerateRazorTargetAssemblyInfo>
<!-- Set to true, to automatically include some AssemblyAttributes inferred from the project metadata in the generated Razor assembly -->
<EnableDefaultRazorTargetAssemblyInfoAttributes Condition="'$(EnableDefaultRazorTargetAssemblyInfoAttributes)'==''">true</EnableDefaultRazorTargetAssemblyInfoAttributes>
<GeneratedRazorTargetAssemblyInfo Condition="'$(GeneratedRazorTargetAssemblyInfo)'==''">$(IntermediateOutputPath)$(MSBuildProjectName).RazorAssemblyInfo.cs</GeneratedRazorTargetAssemblyInfo>
<_GeneratedRazorAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorAssemblyInfoInputs.cache</_GeneratedRazorAssemblyInfoInputsCacheFile>
</PropertyGroup>
<PropertyGroup>
<GenerateRazorAssemblyInfoDependsOn>
GetRazorAssemblyAttributes;
CreateRazorGeneratedAssemblyInfoInputsCacheFile;
</GenerateRazorAssemblyInfoDependsOn>
</PropertyGroup>
<Target
Name="GenerateRazorAssemblyInfo"
DependsOnTargets="$(GenerateRazorAssemblyInfoDependsOn)"
Inputs="$(_GeneratedRazorAssemblyInfoInputsCacheFile)"
Outputs="$(GeneratedRazorTargetAssemblyInfo)"
Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true' AND '@(RazorAssemblyAttribute)'!='' AND '@(RazorCompile)'!=''">
<ItemGroup Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true'">
<!-- Ensure the generated assemblyinfo file is not already part of RazorCompile sources -->
<RazorCompile Remove="$(GeneratedRazorTargetAssemblyInfo)" />
<RazorCompile Include="$(GeneratedRazorTargetAssemblyInfo)" />
</ItemGroup>
<WriteCodeFragment AssemblyAttributes="@(RazorAssemblyAttribute)" Language="C#" OutputFile="$(GeneratedRazorTargetAssemblyInfo)" />
<ItemGroup>
<FileWrites Include="$(GeneratedRazorTargetAssemblyInfo)" />
</ItemGroup>
</Target>
<Target
Name="GetRazorAssemblyAttributes"
DependsOnTargets="GetAssemblyVersion"
Condition="'$(EnableDefaultRazorTargetAssemblyInfoAttributes)'=='true'">
<PropertyGroup>
<RazorAssemblyFileVersion Condition="'$(RazorAssemblyFileVersion)' == ''">$(FileVersion)</RazorAssemblyFileVersion>
<RazorAssemblyInformationalVersion Condition="'$(RazorAssemblyInformationalVersion)' == ''">$(InformationalVersion)</RazorAssemblyInformationalVersion>
<RazorAssemblyTitle Condition="'$(RazorAssemblyTitle)'==''">$(RazorTargetName)</RazorAssemblyTitle>
<RazorAssemblyVersion Condition="'$(RazorAssemblyVersion)' == ''">$(AssemblyVersion)</RazorAssemblyVersion>
</PropertyGroup>
<ItemGroup>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyCompanyAttribute" Condition="'$(Company)' != '' and '$(GenerateAssemblyCompanyAttribute)' == 'true'">
<_Parameter1>$(Company)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyConfigurationAttribute" Condition="'$(Configuration)' != '' and '$(GenerateAssemblyConfigurationAttribute)' == 'true'">
<_Parameter1>$(Configuration)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyCopyrightAttribute" Condition="'$(Copyright)' != '' and '$(GenerateAssemblyCopyrightAttribute)' == 'true'">
<_Parameter1>$(Copyright)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyProductAttribute" Condition="'$(Product)' != '' and '$(GenerateAssemblyProductAttribute)' == 'true'">
<_Parameter1>$(Product)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyFileVersionAttribute" Condition="'$(RazorAssemblyFileVersion)' != '' and '$(GenerateAssemblyFileVersionAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyFileVersion)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyInformationalVersionAttribute" Condition="'$(RazorAssemblyInformationalVersion)' != '' and '$(GenerateAssemblyInformationalVersionAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyInformationalVersion)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyTitleAttribute" Condition="'$(RazorAssemblyTitle)' != '' and '$(GenerateAssemblyTitleAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyTitle)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyVersionAttribute" Condition="'$(RazorAssemblyVersion)' != '' and '$(GenerateAssemblyVersionAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyVersion)</_Parameter1>
</RazorAssemblyAttribute>
</ItemGroup>
</Target>
<!--
To allow version changes to be respected on incremental builds (e.g. through CLI parameters),
create a hash of all assembly attributes so that the cache file will change with the calculated
assembly attribute values and msbuild will then execute CoreGenerateAssembly to generate a new file.
-->
<Target Name="CreateRazorGeneratedAssemblyInfoInputsCacheFile" Condition="'@(RazorAssemblyAttribute)' != ''">
<!-- We only use up to _Parameter1 for most attributes, but other targets may add additional assembly attributes with multiple parameters. -->
<Hash ItemsToHash="@(RazorAssemblyAttribute->'%(Identity)%(_Parameter1)%(_Parameter2)%(_Parameter3)%(_Parameter4)%(_Parameter5)%(_Parameter6)%(_Parameter7)%(_Parameter8)')">
<Output TaskParameter="HashResult" PropertyName="_RazorAssemblyAttributesHash" />
</Hash>
<WriteLinesToFile
Lines="$(_RazorAssemblyAttributesHash)"
File="$(_GeneratedRazorAssemblyInfoInputsCacheFile)"
Overwrite="True"
WriteOnlyWhenDifferent="True" />
<ItemGroup>
<FileWrites Include="$(_GeneratedRazorAssemblyInfoInputsCacheFile)" />
</ItemGroup>
</Target>
</Project>

View File

@ -46,7 +46,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<PrepareForRazorCompileDependsOn> <PrepareForRazorCompileDependsOn>
RazorGenerate; RazorGenerate;
ResolveRazorCompileInputs ResolveRazorCompileInputs;
GenerateRazorAssemblyInfo
</PrepareForRazorCompileDependsOn> </PrepareForRazorCompileDependsOn>
<ResolveRazorCompileInputsDependsOn> <ResolveRazorCompileInputsDependsOn>
@ -106,7 +107,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- File name (without extension) of the assembly produced by Razor --> <!-- File name (without extension) of the assembly produced by Razor -->
<RazorTargetName Condition="'$(RazorTargetName)'==''">$(TargetName)$(RazorTargetNameSuffix)</RazorTargetName> <RazorTargetName Condition="'$(RazorTargetName)'==''">$(TargetName)$(RazorTargetNameSuffix)</RazorTargetName>
<!-- <!--
The compatibility zone - these properties were provided by the MVC Precompilation tool and they The compatibility zone - these properties were provided by the MVC Precompilation tool and they
map to supported settings in Razor SDK. map to supported settings in Razor SDK.
@ -184,6 +185,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<Import Project="$(RazorCodeGenerationTargetsPath)" <Import Project="$(RazorCodeGenerationTargetsPath)"
Condition="'$(RazorCodeGenerationTargetsPath)' != '' AND Exists('$(RazorCodeGenerationTargetsPath)')" /> Condition="'$(RazorCodeGenerationTargetsPath)' != '' AND Exists('$(RazorCodeGenerationTargetsPath)')" />
<Import Project="Microsoft.NET.Sdk.Razor.GenerateAssemblyInfo.targets" />
<!-- <!--
These are the targets that actually do compilation using CSC, separated from the main file for ease of maintenance. These are the targets that actually do compilation using CSC, separated from the main file for ease of maintenance.

View File

@ -66,6 +66,10 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileExists(result, OutputPath, "SimpleMvc.pdb"); Assert.FileExists(result, OutputPath, "SimpleMvc.pdb");
Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll"); Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.dll");
Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb"); Assert.FileDoesNotExist(result, OutputPath, "SimpleMvc.Views.pdb");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.pdb");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
} }
[Fact] [Fact]
@ -270,13 +274,97 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
[Fact] [Fact]
[InitializeTestProject("ClassLibrary")] [InitializeTestProject("ClassLibrary")]
public async Task Build_ClassLibrary_DoesNotProduceDepsFile() public async Task Build_ClassLibrary_DoesNotProduceDepsFileWithCompilationContext()
{ {
var result = await DotnetMSBuild("Build"); var result = await DotnetMSBuild("Build");
Assert.BuildPassed(result); Assert.BuildPassed(result);
Assert.FileExists(result, OutputPath, "ClassLibrary.deps.json");
var depsFilePath = Path.Combine(Project.DirectoryPath, OutputPath, "ClassLibrary.deps.json");
var dependencyContext = ReadDependencyContext(depsFilePath);
Assert.All(dependencyContext.CompileLibraries, library => Assert.Empty(library.Assemblies));
Assert.Empty(dependencyContext.CompilationOptions.Defines);
}
Assert.FileDoesNotExist(result, OutputPath, "ClassLibrary.deps.json"); [Fact]
[InitializeTestProject("ClassLibrary")]
public async Task Build_CodeGensAssemblyInfoUsingValuesFromProject()
{
var assemblyInfoPath = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build");
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfoPath);
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyCopyrightAttribute(\"© Microsoft\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyProductAttribute(\"Razor Test\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyCompanyAttribute(\"Microsoft\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyTitleAttribute(\"ClassLibrary.Views\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyVersionAttribute(\"1.0.0.0\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyFileVersionAttribute(\"1.0.0.0\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyInformationalVersionAttribute(\"1.0.0\")]");
}
[Fact]
[InitializeTestProject("ClassLibrary")]
public async Task Build_UsesRazorSpecificAssemblyProperties()
{
var assemblyInfoPath = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
var buildArguments = "/p:RazorAssemblyFileVersion=2.0.0.100 /p:RazorAssemblyInformationalVersion=2.0.0-preview /p:RazorAssemblyTitle=MyRazorViews /p:RazorAssemblyVersion=2.0.0";
var result = await DotnetMSBuild("Build", buildArguments);
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfoPath);
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyTitleAttribute(\"MyRazorViews\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyVersionAttribute(\"2.0.0\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyFileVersionAttribute(\"2.0.0.100\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyInformationalVersionAttribute(\"2.0.0-preview\")]");
}
[Fact]
[InitializeTestProject("ClassLibrary")]
public async Task Build_DoesNotGenerateAssemblyInfo_IfGenerateRazorTargetAssemblyInfo_IsSetToFalse()
{
var result = await DotnetMSBuild("Build", "/p:GeneratedRazorTargetAssemblyInfo=false");
Assert.BuildPassed(result);
Assert.FileExists(result, IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_AddsApplicationPartAttributes()
{
var assemblyInfoPath = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
var razorAssemblyInfoPath = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build");
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfoPath);
Assert.FileContains(result, assemblyInfoPath, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]");
Assert.FileExists(result, razorAssemblyInfoPath);
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyTitleAttribute(\"SimpleMvc.Views\")]");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFac\"");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_AddsApplicationPartAttributes_WhenEnableDefaultRazorTargetAssemblyInfoAttributes_IsFalse()
{
var razorAssemblyInfoPath = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:EnableDefaultRazorTargetAssemblyInfoAttributes=false");
Assert.BuildPassed(result);
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
Assert.FileExists(result, razorAssemblyInfoPath);
Assert.FileDoesNotContain(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyTitleAttribute");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFac\"");
} }
private static DependencyContext ReadDependencyContext(string depsFilePath) private static DependencyContext ReadDependencyContext(string depsFilePath)

View File

@ -24,5 +24,16 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.BuildOutputContainsLine(result, $"UpToDateCheckInput: {Path.Combine("Views", "Home", "Index.cshtml")}"); Assert.BuildOutputContainsLine(result, $"UpToDateCheckInput: {Path.Combine("Views", "Home", "Index.cshtml")}");
Assert.BuildOutputContainsLine(result, $"UpToDateCheckInput: {Path.Combine("Views", "_ViewStart.cshtml")}"); Assert.BuildOutputContainsLine(result, $"UpToDateCheckInput: {Path.Combine("Views", "_ViewStart.cshtml")}");
} }
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task RazorSdk_AddsGeneratedRazorFilesAndAssemblyInfoToRazorCompile()
{
var result = await DotnetMSBuild("Build", "/t:_IntrospectRazorCompileItems");
Assert.BuildPassed(result);
Assert.BuildOutputContainsLine(result, $"RazorCompile: {Path.Combine(IntermediateOutputPath, "Razor", "Views", "Home", "Index.cs")}");
Assert.BuildOutputContainsLine(result, $"RazorCompile: {Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs")}");
}
} }
} }

View File

@ -70,8 +70,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
[InitializeTestProject("ClassLibrary")] [InitializeTestProject("ClassLibrary")]
public async Task Build_ForClassLibrary_SuppressesConfigurationMetadata() public async Task Build_ForClassLibrary_SuppressesConfigurationMetadata()
{ {
TargetFramework = "netstandard2.0";
var result = await DotnetMSBuild("Build"); var result = await DotnetMSBuild("Build");
Assert.BuildPassed(result); Assert.BuildPassed(result);

View File

@ -35,6 +35,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
} }
MSBuildIntegrationTestBase.Project = ProjectDirectory.Create(_originalProjectName, _testProjectName, _baseDirectory, _additionalProjects); MSBuildIntegrationTestBase.Project = ProjectDirectory.Create(_originalProjectName, _testProjectName, _baseDirectory, _additionalProjects);
MSBuildIntegrationTestBase.TargetFramework = _originalProjectName == "ClassLibrary" ? "netstandard2.0" : "netcoreapp2.0";
} }
public override void After(MethodInfo methodUnderTest) public override void After(MethodInfo methodUnderTest)

View File

@ -14,6 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
public abstract class MSBuildIntegrationTestBase public abstract class MSBuildIntegrationTestBase
{ {
private static readonly AsyncLocal<ProjectDirectory> _project = new AsyncLocal<ProjectDirectory>(); private static readonly AsyncLocal<ProjectDirectory> _project = new AsyncLocal<ProjectDirectory>();
private static readonly AsyncLocal<string> _projectTfm = new AsyncLocal<string>();
protected MSBuildIntegrationTestBase(BuildServerTestFixture buildServer) protected MSBuildIntegrationTestBase(BuildServerTestFixture buildServer)
{ {
@ -43,7 +44,11 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
protected string RazorIntermediateOutputPath => Path.Combine(IntermediateOutputPath, "Razor"); protected string RazorIntermediateOutputPath => Path.Combine(IntermediateOutputPath, "Razor");
protected string TargetFramework { get; set; } = "netcoreapp2.0"; internal static string TargetFramework
{
get => _projectTfm.Value;
set => _projectTfm.Value = value;
}
protected BuildServerTestFixture BuildServer { get; set; } protected BuildServerTestFixture BuildServer { get; set; }

View File

@ -19,7 +19,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
[InitializeTestProject("ClassLibrary")] [InitializeTestProject("ClassLibrary")]
public async Task Pack_Works_IncludesRazorAssembly() public async Task Pack_Works_IncludesRazorAssembly()
{ {
TargetFramework = "netstandard2.0";
var result = await DotnetMSBuild("Pack"); var result = await DotnetMSBuild("Pack");
Assert.BuildPassed(result); Assert.BuildPassed(result);
@ -89,7 +88,6 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
[InitializeTestProject("ClassLibrary")] [InitializeTestProject("ClassLibrary")]
public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet() public async Task Pack_IncludesRazorFilesAsContent_WhenIncludeRazorContentInPack_IsSet()
{ {
TargetFramework = "netstandard2.0";
var result = await DotnetMSBuild("Pack", "/p:IncludeRazorContentInPack=true"); var result = await DotnetMSBuild("Pack", "/p:IncludeRazorContentInPack=true");
Assert.BuildPassed(result); Assert.BuildPassed(result);

View File

@ -0,0 +1,10 @@
// 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.Mvc.ApplicationParts
{
public class CompiledRazorAssemblyApplicationPartFactory
{
}
}

View File

@ -0,0 +1,19 @@
// 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;
namespace Microsoft.AspNetCore.Mvc.ApplicationParts
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public sealed class ProvideApplicationPartFactoryAttribute : Attribute
{
public ProvideApplicationPartFactoryAttribute(Type factoryType)
{
}
public ProvideApplicationPartFactoryAttribute(string factoryTypeName)
{
}
}
}

View File

@ -0,0 +1,15 @@
// 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;
namespace Microsoft.AspNetCore.Mvc.ApplicationParts
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class RelatedAssemblyAttribute : Attribute
{
public RelatedAssemblyAttribute(string name)
{
}
}
}

View File

@ -14,6 +14,10 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<Copyright>© Microsoft</Copyright>
<Product>Razor Test</Product>
<Company>Microsoft</Company>
</PropertyGroup> </PropertyGroup>
<!-- Test Placeholder --> <!-- Test Placeholder -->

View File

@ -10,9 +10,14 @@
<RazorSdkCurrentVersionTargets>$(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets</RazorSdkCurrentVersionTargets> <RazorSdkCurrentVersionTargets>$(SolutionRoot)src\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Sdk.Razor.CurrentVersion.targets</RazorSdkCurrentVersionTargets>
</PropertyGroup> </PropertyGroup>
<!-- Don't use the server when building in place. This locks up rzc.dll -->
<PropertyGroup Condition="'$(BinariesRoot)'==''">
<UseRazorBuildServer>false</UseRazorBuildServer>
</PropertyGroup>
<ItemGroup Condition="'$(BinariesRoot)'==''"> <ItemGroup Condition="'$(BinariesRoot)'==''">
<!-- In test scenarios $(BinariesRoot) is defined in a generated Directory.Build.props file --> <!-- In test scenarios $(BinariesRoot) is defined in a generated Directory.Build.props file -->
<ProjectReference Include="..\..\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj"/> <ProjectReference Include="..\..\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib\Microsoft.AspNetCore.Razor.Test.MvcShim.ClassLib.csproj"/>
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj"/> <ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Razor.Runtime\Microsoft.AspNetCore.Razor.Runtime.csproj"/>
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Razor.Design\Microsoft.AspNetCore.Razor.Design.csproj" ReferenceOutputAssembly="false" /> <ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Razor.Design\Microsoft.AspNetCore.Razor.Design.csproj" ReferenceOutputAssembly="false" />
</ItemGroup> </ItemGroup>

View File

@ -10,4 +10,8 @@
<Target Name="_IntrospectUpToDateCheckInput"> <Target Name="_IntrospectUpToDateCheckInput">
<Message Text="UpToDateCheckInput: %(UpToDateCheckInput.Identity)" Importance="High" /> <Message Text="UpToDateCheckInput: %(UpToDateCheckInput.Identity)" Importance="High" />
</Target> </Target>
<Target Name="_IntrospectRazorCompileItems">
<Message Text="RazorCompile: %(RazorCompile.Identity)" Importance="High" />
</Target>
</Project> </Project>