Continue generating RelatedAssemblyPart on assembly if GenerateAssemblyInfo=false

Fixes #2257
This commit is contained in:
Pranav K 2018-04-12 14:42:25 -07:00
parent 60b6ec047d
commit 95835d6c37
7 changed files with 237 additions and 158 deletions

View File

@ -1,11 +1,14 @@
<Project>
<PropertyGroup>
<!--
Determines if the Sdk is allowed to add additional attributes to the project assembly.
For instance, MVC will generally want to add attributes to support view discovery and runtime compilation.
-->
<GenerateRazorAssemblyInfo Condition="'$(GenerateRazorAssemblyInfo)'==''">true</GenerateRazorAssemblyInfo>
<!--
MVC will generally want to add support for runtime compilation, but only for applications.
-->
<GenerateRazorAssemblyInfo Condition="'$(GenerateRazorAssemblyInfo)'==''">true</GenerateRazorAssemblyInfo>
<GenerateRazorHostingAssemblyInfo Condition="'$(GenerateRazorHostingAssemblyInfo)'=='' AND '$(OutputType)'=='exe'">$(GenerateRazorAssemblyInfo)</GenerateRazorHostingAssemblyInfo>
<!--
@ -20,14 +23,14 @@
</PropertyGroup>
<ItemGroup Condition="'$(GenerateRazorAssemblyInfo)'=='true' AND '$(ResolvedRazorCompileToolset)'=='RazorSdk' AND ('$(RazorCompileOnBuild)' == 'true' OR '$(RazorCompileOnPublish)' == 'true')">
<AssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute">
<_RazorAssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute">
<_Parameter1>$(RazorTargetName)</_Parameter1>
</AssemblyAttribute>
</_RazorAssemblyAttribute>
</ItemGroup>
<ItemGroup Condition="'$(GenerateProvideApplicationPartFactoryAttribute)' == 'true' AND '$(ProvideApplicationPartFactoryAttributeTypeName)'!=''">
<RazorAssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute">
<RazorTargetAssemblyAttribute Include="Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute">
<_Parameter1>$(ProvideApplicationPartFactoryAttributeTypeName)</_Parameter1>
</RazorAssemblyAttribute>
</RazorTargetAssemblyAttribute>
</ItemGroup>
</Project>

View File

@ -12,53 +12,55 @@ 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>
<!-- AssemblyInfo that gets added to the generated Razor dll -->
<RazorTargetAssemblyInfo Condition="'$(RazorTargetAssemblyInfo)'==''">$(IntermediateOutputPath)$(MSBuildProjectName).RazorTargetAssemblyInfo.cs</RazorTargetAssemblyInfo>
<_RazorTargetAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorTargetAssemblyInfo.cache</_RazorTargetAssemblyInfoInputsCacheFile>
<_GeneratedRazorAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorAssemblyInfoInputs.cache</_GeneratedRazorAssemblyInfoInputsCacheFile>
<!-- AssemblyInfo that gets added to the project being compiled -->
<_RazorAssemblyInfo>$(IntermediateOutputPath)$(MSBuildProjectName).RazorAssemblyInfo.cs</_RazorAssemblyInfo>
<_RazorAssemblyInfoInputsCacheFile>$(IntermediateOutputPath)$(MSBuildProjectName).RazorAssemblyInfo.cache</_RazorAssemblyInfoInputsCacheFile>
</PropertyGroup>
<PropertyGroup>
<GenerateRazorAssemblyInfoDependsOn>
GetRazorAssemblyAttributes;
CreateRazorGeneratedAssemblyInfoInputsCacheFile;
CoreGenerateRazorAssemblyInfo
</GenerateRazorAssemblyInfoDependsOn>
<GenerateRazorTargetAssemblyInfoDependsOn>
GetRazorTargetAssemblyAttributes;
_CreateRazorTargetAssemblyInfoInputsCacheFile;
CoreGenerateRazorTargetAssemblyInfo
</GenerateRazorTargetAssemblyInfoDependsOn>
</PropertyGroup>
<Target
Name="GenerateRazorAssemblyInfo"
DependsOnTargets="$(GenerateRazorAssemblyInfoDependsOn)"
Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true'">
Name="GenerateRazorTargetAssemblyInfo"
DependsOnTargets="$(GenerateRazorTargetAssemblyInfoDependsOn)">
</Target>
<Target
Name="CoreGenerateRazorAssemblyInfo"
Inputs="$(_GeneratedRazorAssemblyInfoInputsCacheFile)"
Outputs="$(GeneratedRazorTargetAssemblyInfo)"
Condition="'@(RazorCompile)'!=''">
Name="CoreGenerateRazorTargetAssemblyInfo"
Inputs="$(_RazorTargetAssemblyInfoInputsCacheFile)"
Outputs="$(RazorTargetAssemblyInfo)"
Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true' AND '@(RazorCompile)'!=''">
<ItemGroup Condition="'$(GenerateRazorTargetAssemblyInfo)'=='true'">
<!-- Ensure the generated assemblyinfo file is not already part of RazorCompile sources -->
<RazorCompile Remove="$(GeneratedRazorTargetAssemblyInfo)" />
<RazorCompile Include="$(GeneratedRazorTargetAssemblyInfo)" />
<RazorCompile Remove="$(RazorTargetAssemblyInfo)" />
<RazorCompile Include="$(RazorTargetAssemblyInfo)" />
</ItemGroup>
<WriteCodeFragment AssemblyAttributes="@(RazorAssemblyAttribute)" Language="C#" OutputFile="$(GeneratedRazorTargetAssemblyInfo)" />
<WriteCodeFragment AssemblyAttributes="@(RazorTargetAssemblyAttribute)" Language="C#" OutputFile="$(RazorTargetAssemblyInfo)" />
<ItemGroup>
<FileWrites Include="$(GeneratedRazorTargetAssemblyInfo)" />
<FileWrites Include="$(RazorTargetAssemblyInfo)" />
</ItemGroup>
</Target>
<Target
Name="GetRazorAssemblyAttributes"
Name="GetRazorTargetAssemblyAttributes"
DependsOnTargets="GetAssemblyVersion"
Condition="'$(EnableDefaultRazorTargetAssemblyInfoAttributes)'=='true'">
@ -71,37 +73,37 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyGroup>
<ItemGroup>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyCompanyAttribute" Condition="'$(Company)' != '' and '$(GenerateAssemblyCompanyAttribute)' == 'true'">
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyCompanyAttribute" Condition="'$(Company)' != '' and '$(GenerateAssemblyCompanyAttribute)' == 'true'">
<_Parameter1>$(Company)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyConfigurationAttribute" Condition="'$(Configuration)' != '' and '$(GenerateAssemblyConfigurationAttribute)' == 'true'">
</RazorTargetAssemblyAttribute>
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyConfigurationAttribute" Condition="'$(Configuration)' != '' and '$(GenerateAssemblyConfigurationAttribute)' == 'true'">
<_Parameter1>$(Configuration)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyCopyrightAttribute" Condition="'$(Copyright)' != '' and '$(GenerateAssemblyCopyrightAttribute)' == 'true'">
</RazorTargetAssemblyAttribute>
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyCopyrightAttribute" Condition="'$(Copyright)' != '' and '$(GenerateAssemblyCopyrightAttribute)' == 'true'">
<_Parameter1>$(Copyright)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyProductAttribute" Condition="'$(Product)' != '' and '$(GenerateAssemblyProductAttribute)' == 'true'">
</RazorTargetAssemblyAttribute>
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyProductAttribute" Condition="'$(Product)' != '' and '$(GenerateAssemblyProductAttribute)' == 'true'">
<_Parameter1>$(Product)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Resources.NeutralResourcesLanguageAttribute" Condition="'$(NeutralLanguage)' != '' and '$(GenerateNeutralResourcesLanguageAttribute)' == 'true'">
</RazorTargetAssemblyAttribute>
<RazorTargetAssemblyAttribute Include="System.Resources.NeutralResourcesLanguageAttribute" Condition="'$(NeutralLanguage)' != '' and '$(GenerateNeutralResourcesLanguageAttribute)' == 'true'">
<_Parameter1>$(NeutralLanguage)</_Parameter1>
</RazorAssemblyAttribute>
</RazorTargetAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyDescriptionAttribute" Condition="'$(RazorAssemblyDescription)' != '' and '$(GenerateAssemblyDescriptionAttribute)' == 'true'">
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyDescriptionAttribute" Condition="'$(RazorAssemblyDescription)' != '' and '$(GenerateAssemblyDescriptionAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyDescription)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyFileVersionAttribute" Condition="'$(RazorAssemblyFileVersion)' != '' and '$(GenerateAssemblyFileVersionAttribute)' == 'true'">
</RazorTargetAssemblyAttribute>
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyFileVersionAttribute" Condition="'$(RazorAssemblyFileVersion)' != '' and '$(GenerateAssemblyFileVersionAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyFileVersion)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyInformationalVersionAttribute" Condition="'$(RazorAssemblyInformationalVersion)' != '' and '$(GenerateAssemblyInformationalVersionAttribute)' == 'true'">
</RazorTargetAssemblyAttribute>
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyInformationalVersionAttribute" Condition="'$(RazorAssemblyInformationalVersion)' != '' and '$(GenerateAssemblyInformationalVersionAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyInformationalVersion)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyTitleAttribute" Condition="'$(RazorAssemblyTitle)' != '' and '$(GenerateAssemblyTitleAttribute)' == 'true'">
</RazorTargetAssemblyAttribute>
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyTitleAttribute" Condition="'$(RazorAssemblyTitle)' != '' and '$(GenerateAssemblyTitleAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyTitle)</_Parameter1>
</RazorAssemblyAttribute>
<RazorAssemblyAttribute Include="System.Reflection.AssemblyVersionAttribute" Condition="'$(RazorAssemblyVersion)' != '' and '$(GenerateAssemblyVersionAttribute)' == 'true'">
</RazorTargetAssemblyAttribute>
<RazorTargetAssemblyAttribute Include="System.Reflection.AssemblyVersionAttribute" Condition="'$(RazorAssemblyVersion)' != '' and '$(GenerateAssemblyVersionAttribute)' == 'true'">
<_Parameter1>$(RazorAssemblyVersion)</_Parameter1>
</RazorAssemblyAttribute>
</RazorTargetAssemblyAttribute>
</ItemGroup>
</Target>
@ -111,23 +113,73 @@ Copyright (c) .NET Foundation. All rights reserved.
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)' != ''">
<Target Name="_CreateRazorTargetAssemblyInfoInputsCacheFile" Condition="'@(RazorTargetAssemblyAttribute)' != ''">
<!-- 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)')">
<Hash ItemsToHash="@(RazorTargetAssemblyAttribute->'%(Identity)%(_Parameter1)%(_Parameter2)%(_Parameter3)%(_Parameter4)%(_Parameter5)%(_Parameter6)%(_Parameter7)%(_Parameter8)')">
<Output TaskParameter="HashResult" PropertyName="_RazorTargetAssemblyAttributesHash" />
</Hash>
<WriteLinesToFile
Lines="$(_RazorTargetAssemblyAttributesHash)"
File="$(_RazorTargetAssemblyInfoInputsCacheFile)"
Overwrite="True"
WriteOnlyWhenDifferent="True" />
<ItemGroup>
<FileWrites Include="$(_RazorTargetAssemblyInfoInputsCacheFile)" />
</ItemGroup>
</Target>
<Target Name="_CreateRazorAssemblyInfoInputsCacheFile" 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)"
File="$(_RazorAssemblyInfoInputsCacheFile)"
Overwrite="True"
WriteOnlyWhenDifferent="True" />
<ItemGroup>
<FileWrites Include="$(_GeneratedRazorAssemblyInfoInputsCacheFile)" />
<FileWrites Include="$(_RazorAssemblyInfoInputsCacheFile)" />
</ItemGroup>
</Target>
<Target
Name="_CoreGenerateRazorAssemblyInfo"
DependsOnTargets="_CreateRazorAssemblyInfoInputsCacheFile"
Inputs="$(_RazorAssemblyInfoInputsCacheFile)"
Outputs="$(_RazorAssemblyInfo)"
Condition="'@(_RazorAssemblyAttribute)' != ''">
<ItemGroup Condition="'$(GenerateRazorAssemblyInfo)'=='true'">
<Compile Remove="$(_RazorAssemblyInfo)" />
<Compile Include="$(_RazorAssemblyInfo)" />
</ItemGroup>
<WriteCodeFragment AssemblyAttributes="@(_RazorAssemblyAttribute)" Language="$(Language)" OutputFile="$(_RazorAssemblyInfo)" />
<ItemGroup>
<FileWrites Include="$(_RazorAssemblyInfo)" />
</ItemGroup>
</Target>
<PropertyGroup>
<!-- Generate attributes in the main assembly if we're targeting a C# project and using the Razor Sdk. -->
<CoreCompileDependsOn Condition="'$(ResolvedRazorCompileToolset)'=='RazorSdk' and '$(Language)' == 'C#' and '$(GenerateRazorAssemblyInfo)' == 'true'">
$(CoreCompileDependsOn);_GenerateRazorAssemblyInfo
</CoreCompileDependsOn>
<_GenerateRazorAssemblyInfoDependsOn>PrepareForBuild;_CoreGenerateRazorAssemblyInfo</_GenerateRazorAssemblyInfoDependsOn>
</PropertyGroup>
<Target Name="_GenerateRazorAssemblyInfo" DependsOnTargets="$(_GenerateRazorAssemblyInfoDependsOn)" />
</Project>

View File

@ -47,7 +47,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<PrepareForRazorCompileDependsOn>
RazorGenerate;
ResolveRazorCompileInputs;
GenerateRazorAssemblyInfo
GenerateRazorTargetAssemblyInfo
</PrepareForRazorCompileDependsOn>
<ResolveRazorCompileInputsDependsOn>
@ -230,7 +230,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</Target>
<!--
Generates assembly attributes in support for Razor runtime code generation. This is a set of standard
Gets assembly attributes in support for Razor runtime code generation. This is a set of standard
metadata attributes (defined in Microsoft.AspNetCore.Razor.Runtime) that capture the build-time
Razor configuration of an application to be used at runtime.
@ -240,22 +240,25 @@ Copyright (c) .NET Foundation. All rights reserved.
The SDK expects configurations that use runtime compilation to set $(GenerateRazorHostingAssemblyInfo) to true,
it will be unset by default.
-->
<PropertyGroup>
<_GenerateRazorAssemblyInfoDependsOn>RazorGetAssemblyAttributes;$(_GenerateRazorAssemblyInfoDependsOn)</_GenerateRazorAssemblyInfoDependsOn>
</PropertyGroup>
<Target
Name="RazorGetAssemblyAttributes"
AfterTargets="GetAssemblyAttributes"
Condition="'$(GenerateRazorHostingAssemblyInfo)'=='true' and '$(RazorDefaultConfiguration)'!=''"
DependsOnTargets="ResolveRazorConfiguration">
<ItemGroup>
<AssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute">
<_RazorAssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute">
<_Parameter1>$(RazorLangVersion)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute">
</_RazorAssemblyAttribute>
<_RazorAssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute">
<_Parameter1>$(RazorDefaultConfiguration)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute" Condition="'%(ResolvedRazorExtension.AssemblyName)'!=''">
</_RazorAssemblyAttribute>
<_RazorAssemblyAttribute Include="Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute" Condition="'%(ResolvedRazorExtension.AssemblyName)'!=''">
<_Parameter1>%(ResolvedRazorExtension.Identity)</_Parameter1>
<_Parameter2>%(ResolvedRazorExtension.AssemblyName)</_Parameter2>
</AssemblyAttribute>
</_RazorAssemblyAttribute>
</ItemGroup>
</Target>

View File

@ -1,7 +1,6 @@
// 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.Collections.Generic;
using System.IO;
using System.Linq;

View File

@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.Views.pdb");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs");
}
[Fact]
@ -260,27 +260,27 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
[InitializeTestProject("ClassLibrary")]
public async Task Build_CodeGensAssemblyInfoUsingValuesFromProject()
{
var assemblyInfoPath = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
var razorAssemblyInfoPath = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.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\")]");
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyDescriptionAttribute(\"ClassLibrary Description\")]");
Assert.FileExists(result, razorAssemblyInfoPath);
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyCopyrightAttribute(\"© Microsoft\")]");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyProductAttribute(\"Razor Test\")]");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyCompanyAttribute(\"Microsoft\")]");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyTitleAttribute(\"ClassLibrary.Views\")]");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyVersionAttribute(\"1.0.0.0\")]");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyFileVersionAttribute(\"1.0.0.0\")]");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyInformationalVersionAttribute(\"1.0.0\")]");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: System.Reflection.AssemblyDescriptionAttribute(\"ClassLibrary Description\")]");
}
[Fact]
[InitializeTestProject("ClassLibrary")]
public async Task Build_UsesRazorSpecificAssemblyProperties()
{
var assemblyInfoPath = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.cs");
var buildArguments = "/p:RazorAssemblyFileVersion=2.0.0.100 /p:RazorAssemblyInformationalVersion=2.0.0-preview " +
"/p:RazorAssemblyTitle=MyRazorViews /p:RazorAssemblyVersion=2.0.0 " +
"/p:RazorAssemblyDescription=MyRazorDescription";
@ -288,172 +288,184 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfoPath);
Assert.FileContains(result, assemblyInfoPath, "[assembly: System.Reflection.AssemblyDescriptionAttribute(\"MyRazorDescription\")]");
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\")]");
Assert.FileExists(result, razorTargetAssemblyInfo);
Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyDescriptionAttribute(\"MyRazorDescription\")]");
Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyTitleAttribute(\"MyRazorViews\")]");
Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyVersionAttribute(\"2.0.0\")]");
Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyFileVersionAttribute(\"2.0.0.100\")]");
Assert.FileContains(result, razorTargetAssemblyInfo, "[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");
var result = await DotnetMSBuild("Build", "/p:GenerateRazorTargetAssemblyInfo=false");
Assert.BuildPassed(result);
Assert.FileExists(result, IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.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 razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.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\"");
Assert.FileContains(result, razorAssemblyInfoPath, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]");
Assert.FileExists(result, razorTargetAssemblyInfo);
Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyTitleAttribute(\"SimpleMvc.Views\")]");
Assert.FileContains(result, razorTargetAssemblyInfo, "[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 razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.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\"");
Assert.FileExists(result, razorTargetAssemblyInfo);
Assert.FileDoesNotContain(result, razorTargetAssemblyInfo, "[assembly: System.Reflection.AssemblyTitleAttribute");
Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFac\"");
}
[Fact]
[InitializeTestProject("ClassLibrary")]
public async Task Build_UsesSpecifiedApplicationPartFactoryTypeName()
{
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:ProvideApplicationPartFactoryAttributeTypeName=CustomFactory");
Assert.BuildPassed(result);
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileContains(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"CustomFactory\"");
Assert.FileExists(result, razorTargetAssemblyInfo);
Assert.FileContains(result, razorTargetAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(\"CustomFactory\"");
}
[Fact]
[InitializeTestProject("ClassLibrary")]
public async Task Build_DoesNotGenerateProvideApplicationPartFactoryAttribute_IfGenerateProvideApplicationPartFactoryAttributeIsUnset()
{
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorTargetAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:GenerateProvideApplicationPartFactoryAttribute=false");
Assert.BuildPassed(result);
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileDoesNotContain(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute");
Assert.FileExists(result, razorTargetAssemblyInfo);
Assert.FileDoesNotContain(result, razorTargetAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_DoesNotAddRelatedAssemblyPart_IfToolSetIsNotRazorSdk()
{
var assemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:RazorCompileToolSet=MvcPrecompilation");
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfo);
Assert.FileDoesNotContain(result, assemblyInfo, "RelatedAssemblyAttribute");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
Assert.FileDoesNotExist(result, razorAssemblyInfo);
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_DoesNotAddRelatedAssemblyPart_IfViewCompilationIsDisabled()
{
var assemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false /p:RazorCompileOnPublish=false");
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfo);
Assert.FileDoesNotContain(result, assemblyInfo, "RelatedAssemblyAttribute");
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileDoesNotContain(result, razorAssemblyInfo, "RelatedAssemblyAttribute");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_AddsRelatedAssemblyPart_IfCompileOnPublishIsAllowed()
{
var assemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:RazorCompileOnBuild=false");
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfo);
Assert.FileContains(result, assemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]");
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileContains(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_AddsRelatedAssemblyPart_IfGenerateAssemblyInfoIsFalse()
{
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:GenerateAssemblyInfo=false");
Assert.BuildPassed(result);
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileContains(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_WithGenerateRazorHostingAssemblyInfoFalse_DoesNotGenerateHostingAttributes()
{
var assemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:GenerateRazorHostingAssemblyInfo=false");
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfo);
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute");
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute");
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute");
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute");
Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute");
Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute");
Assert.FileContains(result, razorAssemblyInfo, "[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute(\"SimpleMvc.Views\")]");
}
[Fact]
[InitializeTestProject("ClassLibrary")]
public async Task Build_DoesNotGenerateHostingAttributes_InClassLibraryProjects()
{
var assemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs");
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs");
var result = await DotnetMSBuild("Build");
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfo);
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute");
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute");
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute");
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute");
Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute");
Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_GeneratesHostingAttributesByDefault()
{
var assemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:GenerateRazorHostingAssemblyInfo=false");
Assert.BuildPassed(result);
Assert.FileExists(result, assemblyInfo);
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute(\"2.1\")");
Assert.FileDoesNotContain(result, assemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute(\"MVC-2-1\")");
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute(\"2.1\")");
Assert.FileDoesNotContain(result, razorAssemblyInfo, "Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute(\"MVC-2-1\")");
}
[Fact]
@ -471,6 +483,40 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileDoesNotExist(result, OutputPath, "SimpleMvcFSharp.Views.dll");
Assert.FileDoesNotExist(result, OutputPath, "SimpleMvcFSharp.Views.pdb");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvcFSharp.RazorAssemblyInfo.cs");
Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvcFSharp.RazorAssemblyInfo.fs");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_WithGenerateRazorAssemblyInfo_False_DoesNotGenerateAssemblyInfo()
{
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:GenerateRazorAssemblyInfo=false");
Assert.BuildPassed(result);
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb");
Assert.FileDoesNotExist(result, razorAssemblyInfo);
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_WithGenerateRazorTargetAssemblyInfo_False_DoesNotGenerateAssemblyInfo()
{
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var razorTargetAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs");
var result = await DotnetMSBuild("Build", "/p:GenerateRazorTargetAssemblyInfo=false");
Assert.BuildPassed(result);
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb");
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileDoesNotExist(result, razorTargetAssemblyInfo);
}
[Fact]

View File

@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.BuildPassed(result);
Assert.BuildOutputContainsLine(result, $"RazorCompile: {Path.Combine(IntermediateOutputPath, "Razor", "Views", "Home", "Index.g.cshtml.cs")}");
Assert.BuildOutputContainsLine(result, $"RazorCompile: {Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs")}");
Assert.BuildOutputContainsLine(result, $"RazorCompile: {Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorTargetAssemblyInfo.cs")}");
}
[Fact]

View File

@ -18,6 +18,7 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
[InitializeTestProject("SimpleMvc")]
public async Task Build_WithMvc_AddsConfigurationMetadata()
{
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "SimpleMvc.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build");
Assert.BuildPassed(result);
@ -25,51 +26,26 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb");
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileContainsLine(
result,
Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs"),
razorAssemblyInfo,
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute(\"2.1\")]");
Assert.FileContainsLine(
result,
Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs"),
razorAssemblyInfo,
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute(\"MVC-2.1\")]");
Assert.FileContainsLine(
result,
Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs"),
razorAssemblyInfo,
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute(\"MVC-2.1\", \"Microsoft.AspNetCore.Mvc.Razor.Extensions\")]");
}
[Fact]
[InitializeTestProject("SimpleMvc")]
public async Task Build_WithGenerateRazorAssemblyInfo_False_SuppressesConfigurationMetadata()
{
var result = await DotnetMSBuild("Build", "/p:GenerateRazorAssemblyInfo=false");
Assert.BuildPassed(result);
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.dll");
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.Views.pdb");
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs");
Assert.FileDoesNotContainLine(
result,
Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs"),
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute(\"2.1\")]");
Assert.FileDoesNotContainLine(
result,
Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs"),
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute(\"MVC-2.1\")]");
Assert.FileDoesNotContainLine(
result,
Path.Combine(IntermediateOutputPath, "SimpleMvc.AssemblyInfo.cs"),
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute(\"MVC-2.1\", \"Microsoft.AspNetCore.Razor.Extensions\")]");
}
[Fact]
[InitializeTestProject("ClassLibrary")]
public async Task Build_ForClassLibrary_SuppressesConfigurationMetadata()
{
var razorAssemblyInfo = Path.Combine(IntermediateOutputPath, "ClassLibrary.RazorAssemblyInfo.cs");
var result = await DotnetMSBuild("Build");
Assert.BuildPassed(result);
@ -77,18 +53,18 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileExists(result, IntermediateOutputPath, "ClassLibrary.Views.dll");
Assert.FileExists(result, IntermediateOutputPath, "ClassLibrary.Views.pdb");
Assert.FileExists(result, IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs");
Assert.FileExists(result, razorAssemblyInfo);
Assert.FileDoesNotContainLine(
result,
Path.Combine(IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs"),
razorAssemblyInfo,
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute(\"2.1\")]");
Assert.FileDoesNotContainLine(
result,
Path.Combine(IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs"),
razorAssemblyInfo,
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute(\"MVC-2.1\")]");
Assert.FileDoesNotContainLine(
result,
Path.Combine(IntermediateOutputPath, "ClassLibrary.AssemblyInfo.cs"),
razorAssemblyInfo,
"[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute(\"MVC-2.1\", \"Microsoft.AspNetCore.Razor.Extensions\")]");
}
}