Use the list of Content files specified in the project as a source
Fixes #59
This commit is contained in:
Родитель
c1ef1e533f
Коммит
501540c76e
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.26014.0
|
VisualStudioVersion = 15.0.26118.1
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation", "src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj", "{4339FC9B-AEC6-442A-B413-A41555ED76C7}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation", "src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj", "{4339FC9B-AEC6-442A-B413-A41555ED76C7}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -19,7 +19,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Ra
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Test", "test\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Test\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Test.csproj", "{E0D75B4E-839F-4F80-9B1F-B33F616BCC5F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Test", "test\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Test\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Test.csproj", "{E0D75B4E-839F-4F80-9B1F-B33F616BCC5F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{87FEE984-F627-4F1E-8995-E5F969B85A19}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
build\common.props = build\common.props
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -65,18 +69,6 @@ Global
|
||||||
{E0D75B4E-839F-4F80-9B1F-B33F616BCC5F}.Release|x64.Build.0 = Release|x64
|
{E0D75B4E-839F-4F80-9B1F-B33F616BCC5F}.Release|x64.Build.0 = Release|x64
|
||||||
{E0D75B4E-839F-4F80-9B1F-B33F616BCC5F}.Release|x86.ActiveCfg = Release|x86
|
{E0D75B4E-839F-4F80-9B1F-B33F616BCC5F}.Release|x86.ActiveCfg = Release|x86
|
||||||
{E0D75B4E-839F-4F80-9B1F-B33F616BCC5F}.Release|x86.Build.0 = Release|x86
|
{E0D75B4E-839F-4F80-9B1F-B33F616BCC5F}.Release|x86.Build.0 = Release|x86
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Debug|x86.ActiveCfg = Debug|x86
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Debug|x86.Build.0 = Debug|x86
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Release|x64.Build.0 = Release|x64
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Release|x86.ActiveCfg = Release|x86
|
|
||||||
{1140C5E1-1C9A-4895-BB7E-C2AB2C320472}.Release|x86.Build.0 = Release|x86
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -11,7 +11,12 @@
|
||||||
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
|
<PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<!-- Workaround for RC3 VS -->
|
||||||
|
<ItemGroup Condition="'$(BuildingInsideVisualStudio)'!='true'">
|
||||||
|
<Compile Include="**\*.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
<PackageReference Include="Internal.AspNetCore.Sdk" Version="1.0.0-alpha-15156" PrivateAssets="All" />
|
<PackageReference Include="Internal.AspNetCore.Sdk" Version="1.0.0-alpha-15156" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using Microsoft.Extensions.CommandLineUtils;
|
using Microsoft.Extensions.CommandLineUtils;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
|
@ -15,6 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
public static readonly string PublicSignTemplate = "--public-sign";
|
public static readonly string PublicSignTemplate = "--public-sign";
|
||||||
public static readonly string ApplicationNameTemplate = "--application-name";
|
public static readonly string ApplicationNameTemplate = "--application-name";
|
||||||
public static readonly string OutputPathTemplate = "--output-path";
|
public static readonly string OutputPathTemplate = "--output-path";
|
||||||
|
public static readonly string ViewsToCompileTemplate = "--file";
|
||||||
|
|
||||||
public CompilationOptions(CommandLineApplication app)
|
public CompilationOptions(CommandLineApplication app)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
|
|
||||||
ProjectArgument = app.Argument(
|
ProjectArgument = app.Argument(
|
||||||
"project",
|
"project",
|
||||||
"The path to the project (project folder or project.json) with precompilation.");
|
"The path to the project file.");
|
||||||
|
|
||||||
ConfigureCompilationType = app.Option(
|
ConfigureCompilationType = app.Option(
|
||||||
ConfigureCompilationTypeTemplate,
|
ConfigureCompilationTypeTemplate,
|
||||||
|
@ -49,7 +51,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
|
|
||||||
KeyFileOption = app.Option(
|
KeyFileOption = app.Option(
|
||||||
StrongNameKeyPath,
|
StrongNameKeyPath,
|
||||||
"Strong name key path",
|
"Strong name key path.",
|
||||||
CommandOptionType.SingleValue);
|
CommandOptionType.SingleValue);
|
||||||
|
|
||||||
DelaySignOption = app.Option(
|
DelaySignOption = app.Option(
|
||||||
|
@ -61,6 +63,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
PublicSignTemplate,
|
PublicSignTemplate,
|
||||||
"Determines if the precompiled view assembly is to be public signed.",
|
"Determines if the precompiled view assembly is to be public signed.",
|
||||||
CommandOptionType.NoValue);
|
CommandOptionType.NoValue);
|
||||||
|
|
||||||
|
ViewsToCompileOption = app.Option(
|
||||||
|
ViewsToCompileTemplate,
|
||||||
|
"Razor files to compile.",
|
||||||
|
CommandOptionType.MultipleValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandArgument ProjectArgument { get; }
|
public CommandArgument ProjectArgument { get; }
|
||||||
|
@ -81,6 +88,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
|
|
||||||
public CommandOption ApplicationNameOption { get; }
|
public CommandOption ApplicationNameOption { get; }
|
||||||
|
|
||||||
|
public CommandOption ViewsToCompileOption { get; }
|
||||||
|
|
||||||
public string OutputPath => OutputPathOption.Value();
|
public string OutputPath => OutputPathOption.Value();
|
||||||
|
|
||||||
public string ApplicationName => ApplicationNameOption.Value();
|
public string ApplicationName => ApplicationNameOption.Value();
|
||||||
|
@ -90,5 +99,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
public bool DelaySign => DelaySignOption.HasValue();
|
public bool DelaySign => DelaySignOption.HasValue();
|
||||||
|
|
||||||
public bool PublicSign => PublicSignOption.HasValue();
|
public bool PublicSign => PublicSignOption.HasValue();
|
||||||
|
|
||||||
|
public List<string> ViewsToCompile => ViewsToCompileOption.Values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,15 +38,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
Host = serviceProvider.GetRequiredService<IMvcRazorHost>();
|
Host = serviceProvider.GetRequiredService<IMvcRazorHost>();
|
||||||
Compiler = serviceProvider.GetRequiredService<CSharpCompiler>();
|
Compiler = serviceProvider.GetRequiredService<CSharpCompiler>();
|
||||||
ViewEngineOptions = serviceProvider.GetRequiredService<IOptions<RazorViewEngineOptions>>().Value;
|
ViewEngineOptions = serviceProvider.GetRequiredService<IOptions<RazorViewEngineOptions>>().Value;
|
||||||
FileProvider = serviceProvider.GetRequiredService<IRazorViewEngineFileProviderAccessor>().FileProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMvcRazorHost Host { get; }
|
public IMvcRazorHost Host { get; }
|
||||||
|
|
||||||
public CSharpCompiler Compiler { get; }
|
public CSharpCompiler Compiler { get; }
|
||||||
|
|
||||||
public IFileProvider FileProvider { get; }
|
|
||||||
|
|
||||||
public RazorViewEngineOptions ViewEngineOptions { get; }
|
public RazorViewEngineOptions ViewEngineOptions { get; }
|
||||||
|
|
||||||
private IDesignTimeMvcBuilderConfiguration GetConfigureCompilationAction(string configureCompilationType)
|
private IDesignTimeMvcBuilderConfiguration GetConfigureCompilationAction(string configureCompilationType)
|
||||||
|
|
|
@ -16,7 +16,6 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using Microsoft.CodeAnalysis.Emit;
|
using Microsoft.CodeAnalysis.Emit;
|
||||||
using Microsoft.CodeAnalysis.Text;
|
using Microsoft.CodeAnalysis.Text;
|
||||||
using Microsoft.Extensions.CommandLineUtils;
|
using Microsoft.Extensions.CommandLineUtils;
|
||||||
using Microsoft.Extensions.FileProviders;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
{
|
{
|
||||||
|
@ -109,11 +108,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
var resources = new ResourceDescription[results.Length];
|
var resources = new ResourceDescription[results.Length];
|
||||||
for (var i = 0; i < results.Length; i++)
|
for (var i = 0; i < results.Length; i++)
|
||||||
{
|
{
|
||||||
var fileInfo = results[i].RelativeFileInfo;
|
var fileInfo = results[i].ViewFileInfo;
|
||||||
|
|
||||||
resources[i] = new ResourceDescription(
|
resources[i] = new ResourceDescription(
|
||||||
fileInfo.RelativePath.Replace('\\', '/'),
|
fileInfo.ViewEnginePath,
|
||||||
fileInfo.FileInfo.CreateReadStream,
|
fileInfo.CreateReadStream,
|
||||||
isPublic: true);
|
isPublic: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,9 +170,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
{
|
{
|
||||||
var result = results[i];
|
var result = results[i];
|
||||||
var sourceText = SourceText.From(result.GeneratorResults.GeneratedCode, Encoding.UTF8);
|
var sourceText = SourceText.From(result.GeneratorResults.GeneratedCode, Encoding.UTF8);
|
||||||
var fileInfo = result.RelativeFileInfo;
|
var fileInfo = result.ViewFileInfo;
|
||||||
var syntaxTree = compiler.CreateSyntaxTree(sourceText)
|
var syntaxTree = compiler.CreateSyntaxTree(sourceText)
|
||||||
.WithFilePath(fileInfo.FileInfo.PhysicalPath ?? fileInfo.RelativePath);
|
.WithFilePath(fileInfo.FullPath ?? fileInfo.ViewEnginePath);
|
||||||
syntaxTrees[i] = syntaxTree;
|
syntaxTrees[i] = syntaxTree;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -231,15 +230,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
|
|
||||||
private ViewCompilationInfo[] GenerateCode()
|
private ViewCompilationInfo[] GenerateCode()
|
||||||
{
|
{
|
||||||
var files = new List<RelativeFileInfo>();
|
var files = GetRazorFiles();
|
||||||
GetRazorFiles(MvcServiceProvider.FileProvider, files, root: string.Empty);
|
|
||||||
var results = new ViewCompilationInfo[files.Count];
|
var results = new ViewCompilationInfo[files.Count];
|
||||||
Parallel.For(0, results.Length, ParalellOptions, i =>
|
Parallel.For(0, results.Length, ParalellOptions, i =>
|
||||||
{
|
{
|
||||||
var fileInfo = files[i];
|
var fileInfo = files[i];
|
||||||
using (var fileStream = fileInfo.FileInfo.CreateReadStream())
|
using (var fileStream = fileInfo.CreateReadStream())
|
||||||
{
|
{
|
||||||
var result = MvcServiceProvider.Host.GenerateCode(fileInfo.RelativePath, fileStream);
|
var result = MvcServiceProvider.Host.GenerateCode(fileInfo.ViewEnginePath, fileStream);
|
||||||
results[i] = new ViewCompilationInfo(fileInfo, result);
|
results[i] = new ViewCompilationInfo(fileInfo, result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -247,20 +245,24 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GetRazorFiles(IFileProvider fileProvider, List<RelativeFileInfo> razorFiles, string root)
|
private List<ViewFileInfo> GetRazorFiles()
|
||||||
{
|
{
|
||||||
foreach (var fileInfo in fileProvider.GetDirectoryContents(root))
|
var contentRoot = Options.ContentRootOption.Value();
|
||||||
|
var viewFiles = Options.ViewsToCompile;
|
||||||
|
var relativeFiles = new List<ViewFileInfo>(viewFiles.Count);
|
||||||
|
var trimLength = contentRoot.EndsWith("/") ? contentRoot.Length - 1 : contentRoot.Length;
|
||||||
|
|
||||||
|
for (var i = 0; i < viewFiles.Count; i++)
|
||||||
{
|
{
|
||||||
var relativePath = Path.Combine(root, fileInfo.Name);
|
var fullPath = viewFiles[i];
|
||||||
if (fileInfo.IsDirectory)
|
if (fullPath.StartsWith(contentRoot, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
GetRazorFiles(fileProvider, razorFiles, relativePath);
|
var viewEnginePath = fullPath.Substring(trimLength).Replace('\\', '/');
|
||||||
}
|
relativeFiles.Add(new ViewFileInfo(fullPath, viewEnginePath));
|
||||||
else if (fileInfo.Name.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
razorFiles.Add(new RelativeFileInfo(fileInfo, relativePath));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return relativeFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ReadTypeInfo(CSharpCompilation compilation, SyntaxTree syntaxTree)
|
private string ReadTypeInfo(CSharpCompilation compilation, SyntaxTree syntaxTree)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc.Razor.Compilation;
|
|
||||||
using Microsoft.AspNetCore.Razor.CodeGenerators;
|
using Microsoft.AspNetCore.Razor.CodeGenerators;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
|
@ -9,14 +8,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
public class ViewCompilationInfo
|
public class ViewCompilationInfo
|
||||||
{
|
{
|
||||||
public ViewCompilationInfo(
|
public ViewCompilationInfo(
|
||||||
RelativeFileInfo relativeFileInfo,
|
ViewFileInfo viewFileInfo,
|
||||||
GeneratorResults generatorResults)
|
GeneratorResults generatorResults)
|
||||||
{
|
{
|
||||||
RelativeFileInfo = relativeFileInfo;
|
ViewFileInfo = viewFileInfo;
|
||||||
GeneratorResults = generatorResults;
|
GeneratorResults = generatorResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelativeFileInfo RelativeFileInfo { get; }
|
public ViewFileInfo ViewFileInfo { get; }
|
||||||
|
|
||||||
public GeneratorResults GeneratorResults { get; }
|
public GeneratorResults GeneratorResults { get; }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
// 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.IO;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
|
{
|
||||||
|
public struct ViewFileInfo
|
||||||
|
{
|
||||||
|
public ViewFileInfo(string fullPath, string viewEnginePath)
|
||||||
|
{
|
||||||
|
FullPath = fullPath;
|
||||||
|
ViewEnginePath = viewEnginePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FullPath { get; }
|
||||||
|
|
||||||
|
public string ViewEnginePath { get; }
|
||||||
|
|
||||||
|
public Stream CreateReadStream()
|
||||||
|
{
|
||||||
|
// We are setting buffer size to 1 to prevent FileStream from allocating it's internal buffer
|
||||||
|
// 0 causes constructor to throw
|
||||||
|
var bufferSize = 1;
|
||||||
|
return new FileStream(
|
||||||
|
FullPath,
|
||||||
|
FileMode.Open,
|
||||||
|
FileAccess.Read,
|
||||||
|
FileShare.ReadWrite,
|
||||||
|
bufferSize,
|
||||||
|
FileOptions.Asynchronous | FileOptions.SequentialScan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal
|
||||||
var precompiledViewsArray = new StringBuilder();
|
var precompiledViewsArray = new StringBuilder();
|
||||||
foreach (var item in result)
|
foreach (var item in result)
|
||||||
{
|
{
|
||||||
var path = item.RelativeFileInfo.RelativePath;
|
var path = item.ViewFileInfo.ViewEnginePath;
|
||||||
precompiledViewsArray.AppendLine(
|
precompiledViewsArray.AppendLine(
|
||||||
$"new global::{typeof(ViewInfo).FullName}(@\"{path}\", typeof({item.TypeName})),");
|
$"new global::{typeof(ViewInfo).FullName}(@\"{path}\", typeof({item.TypeName})),");
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,8 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs" />
|
|
||||||
<None Include="build\**\*" Pack="true" PackagePath="%(Identity)" />
|
<None Include="build\**\*" Pack="true" PackagePath="%(Identity)" />
|
||||||
<None Include="buildMultiTargeting/*" Pack="true" PackagePath="%(Identity)" />
|
<None Include="buildMultiTargeting/*" Pack="true" PackagePath="%(Identity)" />
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<Target Name="_ResolveInputArguments">
|
||||||
<_MvcRazorOutputPath Condition="'$(MvcRazorOutputPath)'!=''">$([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)'))</_MvcRazorOutputPath>
|
<PropertyGroup>
|
||||||
<_MvcRazorOutputPath Condition="'$(_MvcRazorOutputPath)'==''">$(IntermediateOutputPath)</_MvcRazorOutputPath>
|
<_MvcRazorOutputPath Condition="'$(MvcRazorOutputPath)'!=''">$([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)'))</_MvcRazorOutputPath>
|
||||||
<_MvcRazorOutputFullPath>$([System.IO.Path]::Combine($(_MvcRazorOutputPath), '$(MSBuildProjectName).PrecompiledViews.dll'))</_MvcRazorOutputFullPath>
|
<_MvcRazorOutputPath Condition="'$(_MvcRazorOutputPath)'==''">$(IntermediateOutputPath)</_MvcRazorOutputPath>
|
||||||
<_MvcRazorResponseFilePath>$(IntermediateOutputPath)microsoft.aspnetcore.mvc.razor.viewcompilation.rsp</_MvcRazorResponseFilePath>
|
<_MvcRazorOutputFullPath>$(_MvcRazorOutputPath)$(MSBuildProjectName).PrecompiledViews.dll</_MvcRazorOutputFullPath>
|
||||||
|
<_MvcRazorResponseFilePath>$(IntermediateOutputPath)microsoft.aspnetcore.mvc.razor.viewcompilation.rsp</_MvcRazorResponseFilePath>
|
||||||
|
|
||||||
<MvcRazorContentRoot Condition="'$(MvcRazorContentRoot)'==''">$(MSBuildProjectDirectory)</MvcRazorContentRoot>
|
<MvcRazorContentRoot Condition="'$(MvcRazorContentRoot)'==''">$(MSBuildProjectDirectory)</MvcRazorContentRoot>
|
||||||
<MvcRazorExcludeViewFilesFromPublish Condition="'$(MvcRazorExcludeViewFilesFromPublish)'==''">true</MvcRazorExcludeViewFilesFromPublish>
|
<MvcRazorExcludeViewFilesFromPublish Condition="'$(MvcRazorExcludeViewFilesFromPublish)'==''">true</MvcRazorExcludeViewFilesFromPublish>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup Condition="'@(MvcRazorFilesToCompile)' == ''">
|
||||||
<_MvcRazorContentFiles Include="$([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)'))**\*.cshtml" />
|
<MvcRazorFilesToCompile Include="@(Content)" Condition="'%(Extension)'=='.cshtml'" />
|
||||||
<Content
|
</ItemGroup>
|
||||||
Update="**\*.cshtml"
|
</Target>
|
||||||
CopyToPublishDirectory="Never"
|
|
||||||
Condition="'$(MvcRazorCompileOnPublish)'=='true' AND '$(MvcRazorExcludeViewFilesFromPublish)'=='true'" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<Target Name="_CreateResponseFileForMvcRazorPrecompile">
|
<Target Name="_CreateResponseFileForMvcRazorPrecompile">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -28,6 +26,8 @@
|
||||||
<ExecArgs
|
<ExecArgs
|
||||||
Condition="'$(MvcRazorEmbedViewSources)'=='true'"
|
Condition="'$(MvcRazorEmbedViewSources)'=='true'"
|
||||||
Include="--embed-view-sources" />
|
Include="--embed-view-sources" />
|
||||||
|
|
||||||
|
<ExecArgs Include="--file=%(MvcRazorFilesToCompile.FullPath)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(SignAssembly)'=='true'">
|
<ItemGroup Condition="'$(SignAssembly)'=='true'">
|
||||||
|
@ -46,13 +46,21 @@
|
||||||
Overwrite="true" />
|
Overwrite="true" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target
|
<Target
|
||||||
Name="_MvcRazorPrecompileOnPublish"
|
Name="_MvcRazorPrecompileOnPublish"
|
||||||
DependsOnTargets="MvcRazorPrecompile"
|
DependsOnTargets="MvcRazorPrecompile"
|
||||||
AfterTargets="PrepareForPublish"
|
AfterTargets="PrepareForPublish"
|
||||||
Condition="'$(MvcRazorCompileOnPublish)'=='true'">
|
Condition="'$(MvcRazorCompileOnPublish)'=='true'" />
|
||||||
|
|
||||||
|
<Target Name="_MvcRazorResolveFilesToCompute"
|
||||||
|
AfterTargets="ComputeFilesToPublish"
|
||||||
|
Condition="'$(MvcRazorCompileOnPublish)'=='true'">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ResolvedFileToPublish
|
||||||
|
Remove="%(MvcRazorFilesToCompile.FullPath)"
|
||||||
|
Condition="'$(MvcRazorExcludeViewFilesFromPublish)'=='true'" />
|
||||||
|
|
||||||
<ResolvedFileToPublish Include="$(_MvcRazorOutputFullPath)" CopyToPublishDirectory="Always">
|
<ResolvedFileToPublish Include="$(_MvcRazorOutputFullPath)" CopyToPublishDirectory="Always">
|
||||||
<RelativePath>$([System.IO.Path]::GetFileName('$(_MvcRazorOutputFullPath)'))</RelativePath>
|
<RelativePath>$([System.IO.Path]::GetFileName('$(_MvcRazorOutputFullPath)'))</RelativePath>
|
||||||
</ResolvedFileToPublish>
|
</ResolvedFileToPublish>
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
<Target
|
<Target
|
||||||
Name="MvcRazorPrecompile"
|
Name="MvcRazorPrecompile"
|
||||||
Inputs="$(MSBuildThisFileFullPath);@(_MvcRazorContentFiles);@(IntermediateAssembly);@(DocFileItem);@(_DebugSymbolsIntermediatePath);@(ReferencePath);$(MSBuildAllProjects);"
|
DependsOnTargets="_ResolveInputArguments"
|
||||||
|
Inputs="$(MSBuildThisFileFullPath);@(MvcRazorFilesToCompile);@(IntermediateAssembly);@(DocFileItem);@(_DebugSymbolsIntermediatePath);@(ReferencePath);$(MSBuildAllProjects);"
|
||||||
Outputs="$(_MvcRazorOutputFullPath)">
|
Outputs="$(_MvcRazorOutputFullPath)">
|
||||||
|
|
||||||
<CallTarget Targets="_CreateResponseFileForMvcRazorPrecompile" />
|
<CallTarget Targets="_CreateResponseFileForMvcRazorPrecompile" />
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Target
|
<Target
|
||||||
Name="MvcRazorPrecompile"
|
Name="MvcRazorPrecompile"
|
||||||
Inputs="$(MSBuildThisFileFullPath);@(_MvcRazorContentFiles);@(IntermediateAssembly);@(DocFileItem);@(_DebugSymbolsIntermediatePath);@(ReferencePath);$(MSBuildAllProjects)"
|
DependsOnTargets="_ResolveInputArguments"
|
||||||
|
Inputs="$(MSBuildThisFileFullPath);@(MvcRazorFilesToCompile);@(IntermediateAssembly);@(DocFileItem);@(_DebugSymbolsIntermediatePath);@(ReferencePath);$(MSBuildAllProjects)"
|
||||||
Outputs="$(_MvcRazorOutputFullPath)">
|
Outputs="$(_MvcRazorOutputFullPath)">
|
||||||
|
|
||||||
<CallTarget Targets="_CreateResponseFileForMvcRazorPrecompile" />
|
<CallTarget Targets="_CreateResponseFileForMvcRazorPrecompile" />
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
// 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 Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
|
{
|
||||||
|
public class ApplicationWithCustomInputFilesTest
|
||||||
|
: IClassFixture<ApplicationWithCustomInputFilesTest.ApplicationWithCustomInputFilesTestFixture>
|
||||||
|
{
|
||||||
|
private const string ApplicationName = "ApplicationWithCustomInputFiles";
|
||||||
|
|
||||||
|
public ApplicationWithCustomInputFilesTest(ApplicationWithCustomInputFilesTestFixture fixture)
|
||||||
|
{
|
||||||
|
Fixture = fixture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationTestFixture Fixture { get; }
|
||||||
|
|
||||||
|
public static TheoryData SupportedFlavorsTheoryData => RuntimeFlavors.SupportedFlavorsTheoryData;
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
|
public async Task ApplicationWithCustomInputFiles_Works(RuntimeFlavor flavor)
|
||||||
|
{
|
||||||
|
var expectedText = "Hello Index!";
|
||||||
|
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var deploymentResult = deployer.Deploy();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var response = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||||
|
deploymentResult.ApplicationBaseUri,
|
||||||
|
Fixture.Logger);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(expectedText, response.Trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
|
public async Task MvcRazorFilesToCompile_OverridesTheFilesToBeCompiled(RuntimeFlavor flavor)
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var expectedViews = new[]
|
||||||
|
{
|
||||||
|
"/Views/Home/About.cshtml",
|
||||||
|
"/Views/Home/Index.cshtml",
|
||||||
|
};
|
||||||
|
|
||||||
|
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||||
|
{
|
||||||
|
var deploymentResult = deployer.Deploy();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var response2 = await Fixture.HttpClient.GetStringWithRetryAsync(
|
||||||
|
$"{deploymentResult.ApplicationBaseUri}Home/GetPrecompiledResourceNames",
|
||||||
|
Fixture.Logger);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var actual = response2.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.OrderBy(p => p, StringComparer.OrdinalIgnoreCase);
|
||||||
|
Assert.Equal(expectedViews, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Theory]
|
||||||
|
[MemberData(nameof(SupportedFlavorsTheoryData))]
|
||||||
|
public void MvcRazorFilesToCompile_SpecificallyDoesNotPublishFilesToBeCompiled(RuntimeFlavor flavor)
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var viewsNotPublished = new[]
|
||||||
|
{
|
||||||
|
"Index.cshtml",
|
||||||
|
"About.cshtml",
|
||||||
|
};
|
||||||
|
|
||||||
|
var viewsPublished = new[]
|
||||||
|
{
|
||||||
|
"NotIncluded.cshtml",
|
||||||
|
};
|
||||||
|
|
||||||
|
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||||
|
{
|
||||||
|
var deploymentResult = deployer.Deploy();
|
||||||
|
var viewsDirectory = Path.Combine(deploymentResult.ContentRoot, "Views", "Home");
|
||||||
|
|
||||||
|
// Act & Assert
|
||||||
|
foreach (var file in viewsPublished)
|
||||||
|
{
|
||||||
|
var filePath = Path.Combine(viewsDirectory, file);
|
||||||
|
Assert.True(File.Exists(filePath), $"{filePath} was not published.");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var file in viewsNotPublished)
|
||||||
|
{
|
||||||
|
var filePath = Path.Combine(viewsDirectory, file);
|
||||||
|
Assert.False(File.Exists(filePath), $"{filePath} was published.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ApplicationWithCustomInputFilesTestFixture : ApplicationTestFixture
|
||||||
|
{
|
||||||
|
public ApplicationWithCustomInputFilesTestFixture()
|
||||||
|
: base(ApplicationWithCustomInputFilesTest.ApplicationName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,6 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs" />
|
|
||||||
<EmbeddedResource Include="Resources\*" />
|
<EmbeddedResource Include="Resources\*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.FunctionalTests
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedViews = new[]
|
var expectedViews = new[]
|
||||||
{
|
{
|
||||||
"Areas/TestArea/Views/Home/Index.cshtml",
|
"/Areas/TestArea/Views/Home/Index.cshtml",
|
||||||
"Views/Home/About.cshtml",
|
"/Views/Home/About.cshtml",
|
||||||
"Views/Home/Index.cshtml",
|
"/Views/Home/Index.cshtml",
|
||||||
};
|
};
|
||||||
var expectedText = "Hello Index!";
|
var expectedText = "Hello Index!";
|
||||||
using (var deployer = Fixture.CreateDeployment(flavor))
|
using (var deployer = Fixture.CreateDeployment(flavor))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
AspNetCore.Areas_Manage_Views_Shared__Layout_cshtml, ClassLibraryWithPrecompiledViews.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Areas_Manage_Views_Shared__Layout_cshtml, ClassLibraryWithPrecompiledViews.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
|
|
||||||
<h1>Admin home page</h1>
|
<h1>Admin home page</h1>
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
AspNetCore.Views_Home_Index_cshtml, ApplicationWithConfigureMvc.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Home_Index_cshtml, ApplicationWithConfigureMvc.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
<br />Hello world!
|
<br />Hello world!
|
|
@ -8,7 +8,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container body-content">
|
<div class="container body-content">
|
||||||
|
|
||||||
AspNetCore.Views_Home_ClassLibraryTagHelper_cshtml, ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Home_ClassLibraryTagHelper_cshtml, ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
<div><b>To boldy tag that no one has ever tagged before...</b></div>
|
<div><b>To boldy tag that no one has ever tagged before...</b></div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,6 @@ AspNetCore.Views_Home_ClassLibraryTagHelper_cshtml, ApplicationWithTagHelpers.Pr
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
AspNetCore.Views_Shared__Layout_cshtml, ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Shared__Layout_cshtml, ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container body-content">
|
<div class="container body-content">
|
||||||
|
|
||||||
AspNetCore.Views_Home_LocalTagHelper_cshtml, ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Home_LocalTagHelper_cshtml, ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
<test href="/Home/About">TestTagHelper content.</test>
|
<test href="/Home/About">TestTagHelper content.</test>
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,6 @@ AspNetCore.Views_Home_LocalTagHelper_cshtml, ApplicationWithTagHelpers.Precompil
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
AspNetCore.Views_Shared__Layout_cshtml, ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Shared__Layout_cshtml, ApplicationWithTagHelpers.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="container body-content">
|
<div class="container body-content">
|
||||||
|
|
||||||
AspNetCore.Views_Home_Index_cshtml, SimpleAppDesktopOnly.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Home_Index_cshtml, SimpleAppDesktopOnly.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
<hr />
|
<hr />
|
||||||
<footer>
|
<footer>
|
||||||
<p>© 2016 - SimpleApp</p>
|
<p>© 2016 - SimpleApp</p>
|
||||||
|
@ -54,6 +54,6 @@ AspNetCore.Views_Home_Index_cshtml, SimpleAppDesktopOnly.PrecompiledViews, Versi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AspNetCore.Views_Shared__Layout_cshtml, SimpleAppDesktopOnly.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Shared__Layout_cshtml, SimpleAppDesktopOnly.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="container body-content">
|
<div class="container body-content">
|
||||||
|
|
||||||
AspNetCore.Views_Home_Index_cshtml, SimpleApp.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Home_Index_cshtml, SimpleApp.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
|
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
|
||||||
<ol class="carousel-indicators">
|
<ol class="carousel-indicators">
|
||||||
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
|
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
|
||||||
|
@ -160,6 +160,6 @@ AspNetCore.Views_Home_Index_cshtml, SimpleApp.PrecompiledViews, Version=1.0.0.0,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AspNetCore.Views_Shared__Layout_cshtml, SimpleApp.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
AspNetCore._Views_Shared__Layout_cshtml, SimpleApp.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Hello from view in AspNetCore.Views_Home_Index_cshtml, StrongNamedApp.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
|
Hello from view in AspNetCore._Views_Home_Index_cshtml, StrongNamedApp.PrecompiledViews, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="**\*.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj" />
|
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -25,18 +25,19 @@ $@"Microsoft Razor Precompilation Utility {GetToolVersion()}
|
||||||
Usage: razor-precompile [arguments] [options]
|
Usage: razor-precompile [arguments] [options]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
project The path to the project (project folder or project.json) with precompilation.
|
project The path to the project file.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-?|-h|--help Show help information
|
-?|-h|--help Show help information
|
||||||
|
--output-path Path to the emit the precompiled assembly to.
|
||||||
|
--application-name Name of the application to produce precompiled assembly for.
|
||||||
--configure-compilation-type Type with Configure method
|
--configure-compilation-type Type with Configure method
|
||||||
--content-root The application's content root.
|
--content-root The application's content root.
|
||||||
--embed-view-sources Embed view sources as resources in the generated assembly.
|
--embed-view-sources Embed view sources as resources in the generated assembly.
|
||||||
--key-file Strong name key path
|
--key-file Strong name key path.
|
||||||
--delay-sign Determines if the precompiled view assembly is to be delay signed.
|
--delay-sign Determines if the precompiled view assembly is to be delay signed.
|
||||||
--public-sign Determines if the precompiled view assembly is to be public signed.
|
--public-sign Determines if the precompiled view assembly is to be public signed.
|
||||||
--output-path Path to the emit the precompiled assembly to.
|
--file Razor files to compile.";
|
||||||
--application-name Name of the application to produce precompiled assembly for.";
|
|
||||||
|
|
||||||
var args = new[]
|
var args = new[]
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netcoreapp1.1;net451</TargetFrameworks>
|
||||||
|
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RuntimeIdentifier Condition="!$(TargetFramework.StartsWith('netcoreapp'))">win7-x64</RuntimeIdentifier>
|
||||||
|
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
|
||||||
|
<MvcRazorEmbedViewSources>true</MvcRazorEmbedViewSources>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<MvcRazorFilesToCompile Include="Views/Home/Index.cshtml;Views/Home/About.cshtml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation">
|
||||||
|
<Version>1.1.0-*</Version>
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="1.1.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
|
||||||
|
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Razor.Compilation;
|
||||||
|
|
||||||
|
namespace ApplicationWithCustomInputFiles.Controllers
|
||||||
|
{
|
||||||
|
public class HomeController : Controller
|
||||||
|
{
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetPrecompiledResourceNames([FromServices] ApplicationPartManager applicationManager)
|
||||||
|
{
|
||||||
|
var feature = new ViewsFeature();
|
||||||
|
applicationManager.PopulateFeature(feature);
|
||||||
|
return string.Join(Environment.NewLine, feature.Views.Keys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace ApplicationWithCustomInputFiles
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var config = new ConfigurationBuilder()
|
||||||
|
.AddCommandLine(args)
|
||||||
|
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var host = new WebHostBuilder()
|
||||||
|
.UseConfiguration(config)
|
||||||
|
.UseKestrel()
|
||||||
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
.UseStartup<Startup>()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
host.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace ApplicationWithCustomInputFiles
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
// Add framework services.
|
||||||
|
services.AddMvc();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||||
|
{
|
||||||
|
loggerFactory.AddConsole();
|
||||||
|
app.UseMvc(routes =>
|
||||||
|
{
|
||||||
|
routes.MapRoute(
|
||||||
|
name: "default",
|
||||||
|
template: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
Hello from About
|
|
@ -0,0 +1 @@
|
||||||
|
Hello Index!
|
|
@ -0,0 +1 @@
|
||||||
|
This file is not included in compilation.
|
Загрузка…
Ссылка в новой задаче