-
Notifications
You must be signed in to change notification settings - Fork 16
Add support for pre-compiling desktop applications. #130
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ build_script: | |
clone_depth: 1 | ||
test: off | ||
deploy: off | ||
os: Visual Studio 2017 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,25 @@ | |
|
||
<PropertyGroup> | ||
<Description>Build-time references required to enable Razor view compilation as part of building the application.</Description> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks> | ||
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks> | ||
<RuntimeIdentifier Condition="!$(TargetFramework.StartsWith('netcoreapp'))">win7-x64</RuntimeIdentifier> | ||
<PackageTags>cshtml;razor;compilation;precompilation;aspnetcore</PackageTags> | ||
<PreserveCompilationContext>true</PreserveCompilationContext> | ||
<OutputType>exe</OutputType> | ||
<!-- Include the build outputs in the build directory (and not the lib directory) --> | ||
<BuildOutputTargetFolder>build</BuildOutputTargetFolder> | ||
<X86ProjectDirectory>..\..\tools\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation-x86\</X86ProjectDirectory> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="build\**\*" Pack="true" PackagePath="%(Identity)" /> | ||
<None Include="$(X86ProjectDirectory)\bin\$(Configuration)\net461\win7-x86\$(MSBuildThisFileName)-x86.exe" Pack="true" PackagePath="lib\net461\$(MSBuildThisFileName)-x86.exe" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="$(AspNetCoreVersion)" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="$(AspNetCoreVersion)" /> | ||
<PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" /> | ||
<ProjectReference Include="$(X86ProjectDirectory)$(MSBuildThisFileName)-x86.csproj" PrivateAssets="true" ReferenceOutputAssembly="false" Condition="'$(TargetFramework)'=='net461'" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we should be able to condense this to one project file. MSBuild is designed to handle this need w/o creating a separate csproj. |
||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildThisFileDirectory)..\common.targets" /> | ||
<PropertyGroup> | ||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
<Target | ||
Name="MvcRazorPrecompile" | ||
DependsOnTargets="_ResolveInputArguments" | ||
Inputs="@(MvcRazorFilesToCompile);@(IntermediateAssembly);@(DocFileItem);@(_DebugSymbolsIntermediatePath);@(ReferencePath);$(MSBuildAllProjects);" | ||
Outputs="$(_MvcRazorOutputFullPath)"> | ||
|
||
<PropertyGroup Condition="'$(MvcRazorRunCommand)'==''"> | ||
<MvcRazorRunCommand>$(OutputPath)$(MSBuildThisFileName).exe</MvcRazorRunCommand> | ||
<MvcRazorRunCommand Condition="'$(PlatformTarget)'=='x86'">$(OutputPath)$(MSBuildThisFileName)-x86.exe</MvcRazorRunCommand> | ||
</PropertyGroup> | ||
|
||
<CallTarget Targets="_CreateResponseFileForMvcRazorPrecompile" /> | ||
|
||
<ItemGroup Condition="'$(PlatformTarget)'=='x86'"> | ||
<_PreCompilationFilesToCopy Include="$(OutputPath)$(AssemblyName).exe.config"> | ||
<Destination>$(OutputPath)$(MSBuildThisFileName)-x86.exe.config</Destination> | ||
</_PreCompilationFilesToCopy> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(PlatformTarget)'!='x86'"> | ||
<_PreCompilationFilesToCopy Include="$(OutputPath)$(AssemblyName).exe.config" Condition=""> | ||
<Destination>$(OutputPath)$(MSBuildThisFileName).exe.config</Destination> | ||
</_PreCompilationFilesToCopy> | ||
</ItemGroup> | ||
|
||
<Copy | ||
SourceFiles="@(_PreCompilationFilesToCopy)" | ||
DestinationFiles="%(Destination)" /> | ||
|
||
<Message | ||
Text="Executing Razor view precompilation." | ||
Importance="Low" /> | ||
|
||
<Exec | ||
Command="$(MvcRazorRunCommand) @"$(_MvcRazorResponseFilePath)"" | ||
WorkingDirectory="$(MSBuildProjectDirectory)"/> | ||
|
||
<Message | ||
Text="Razor view compilation for $(MSBuildProjectName) -> $(_MvcRazorOutputFullPath)" | ||
Importance="High" /> | ||
|
||
<Delete Files="%(_PreCompilationFilesToCopy.Destination)" /> | ||
|
||
</Target> | ||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Server.IntegrationTesting; | ||
using Microsoft.AspNetCore.Testing.xunit; | ||
using Xunit; | ||
|
||
namespace Microsoft.AspNetCore.Mvc.Razor.ViewCompilation | ||
|
@@ -16,9 +18,15 @@ public ApplicationConsumingPrecompiledViews(ApplicationConsumingPrecompiledViews | |
|
||
public ApplicationTestFixture Fixture { get; } | ||
|
||
[Fact] | ||
public async Task ConsumingClassLibrariesWithPrecompiledViewsWork() | ||
public static TheoryData SupportedFlavorsTheoryData => RuntimeFlavors.SupportedFlavorsTheoryData; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: where possible, use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nah, it's more maintenance if you need to change signatures in the future. Same reasoning applies to why we choose to use |
||
|
||
[ConditionalTheory] | ||
[MemberData(nameof(SupportedFlavorsTheoryData))] | ||
public async Task ConsumingClassLibrariesWithPrecompiledViewsWork(RuntimeFlavor flavor) | ||
{ | ||
// Arrange | ||
Fixture.CreateDeployment(flavor); | ||
|
||
// Act | ||
var response = await Fixture.HttpClient.GetStringWithRetryAsync("Manage/Home", Fixture.Logger); | ||
|
||
|
@@ -34,4 +42,4 @@ public ApplicationConsumingPrecompiledViewsFixture() | |
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:thuglife: