Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Move binaries in to the build folder #145

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions build/common-testapps.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
<TestIncludeViewCompilationTargets Condition="'$(TestIncludeViewCompilationTargets)'==''">$(MvcRazorCompileOnPublish)</TestIncludeViewCompilationTargets>
</PropertyGroup>

<Import Project="..\src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\build\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets"
Condition="'$(TestIncludeViewCompilationTargets)'=='true' AND '$(TargetFramework)'=='netcoreapp2.0'"/>

<Import Project="..\src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\build\net461\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets"
Condition="'$(TestIncludeViewCompilationTargets)'=='true' AND '$(TargetFramework)'=='net461'"/>
<Import Project="..\src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets"
Condition="'$(TestIncludeViewCompilationTargets)'=='true'"/>

<ItemGroup Condition="'$(TestIncludeViewCompilationTargets)'=='true'">
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,25 @@
<PreserveCompilationContext>true</PreserveCompilationContext>
<OutputType>exe</OutputType>
<X86ProjectDirectory>..\..\tools\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation-x86\</X86ProjectDirectory>

<!--
This prevents dotnet from automatically generating a lib/tfm/*.dll; in turn we're then able
to exclude the lib/net461 and manually construct only the necessary folders:
- lib/netcoreapp2.0/...
- runtimes/win7-x64/lib/...
- runtimes/win7-x86/lib/...
-->
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<None Include="build\common.targets" Pack="true" PackagePath="%(Identity)" />
<None Include="lib\net461\_._" Pack="true" PackagePath="%(Identity)" />
<None Include="lib\netcoreapp2.0\_._" Pack="true" PackagePath="runtimes\win7-x64\lib\netcoreapp2.0\_._" />
<None Include="lib\netcoreapp2.0\_._" Pack="true" PackagePath="runtimes\win7-x86\lib\netcoreapp2.0\_._" />
<None Include="build\netcoreapp2.0\*" Pack="true" PackagePath="%(Identity)" />
<None Include="bin\$(Configuration)\netcoreapp2.0\$(AssemblyName).dll" Pack="true" PackagePath="lib\netcoreapp2.0\$(AssemblyName).dll" />
<None Include="bin\$(Configuration)\netcoreapp2.0\$(AssemblyName).runtimeconfig.json" Pack="true" PackagePath="lib\netcoreapp2.0\$(AssemblyName).runtimeconfig.json" />
</ItemGroup>

<ItemGroup Condition=" '$(OS)' == 'Windows_NT' ">
<None Include="build\net461\*" Pack="true" PackagePath="%(Identity)" />
<None Include="bin\$(Configuration)\net461\win7-x64\$(AssemblyName).exe" Pack="true" PackagePath="runtimes\win7-x64\lib\net461\$(AssemblyName).exe" />
<None Include="$(X86ProjectDirectory)\bin\$(Configuration)\net461\win7-x86\$(AssemblyName)-x86.exe" Pack="true" PackagePath="runtimes\win7-x86\lib\net461\$(AssemblyName)-x86.exe" />
</ItemGroup>
<ProjectReference Include="$(X86ProjectDirectory)$(MSBuildThisFileName)-x86.csproj" PrivateAssets="true" ReferenceOutputAssembly="false" Condition="'$(TargetFramework)'=='net461'" />

<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'" />
</ItemGroup>

<ItemGroup>
<None Include="build\**\*.*" Pack="true" PackagePath="%(Identity)" />
<None Include="$(OutputPath)netcoreapp2.0\$(AssemblyName).dll" Pack="true" PackagePath="build\netstandard2.0\$(AssemblyName).dll" />
</ItemGroup>

<ItemGroup Condition="'$(OS)'=='Windows_NT'">
<None Include="$(OutputPath)net461\win7-x64\$(AssemblyName).exe" Pack="true" PackagePath="build\netstandard2.0\$(AssemblyName)-x64.exe" />
<None Include="$(X86ProjectDirectory)\bin\$(Configuration)\net461\win7-x86\$(AssemblyName)-x86.exe" Pack="true" PackagePath="build\netstandard2.0\$(AssemblyName)-x86.exe" />
</ItemGroup>

</Project>

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="_ResolveInputArguments">
<PropertyGroup>
<_MvcRazorOutputPath Condition="'$(MvcRazorOutputPath)'!=''">$([MSBuild]::EnsureTrailingSlash('$(MvcRazorOutputPath)'))</_MvcRazorOutputPath>
<_MvcRazorOutputPath Condition="'$(_MvcRazorOutputPath)'==''">$(IntermediateOutputPath)</_MvcRazorOutputPath>
<_MvcRazorOutputFullPath>$(_MvcRazorOutputPath)$(AssemblyName).PrecompiledViews.dll</_MvcRazorOutputFullPath>
<_MvcRazorResponseFilePath>$(IntermediateOutputPath)microsoft.aspnetcore.mvc.razor.viewcompilation.rsp</_MvcRazorResponseFilePath>

<MvcRazorContentRoot Condition="'$(MvcRazorContentRoot)'==''">$(MSBuildProjectDirectory)</MvcRazorContentRoot>
<MvcRazorExcludeViewFilesFromPublish Condition="'$(MvcRazorExcludeViewFilesFromPublish)'==''">true</MvcRazorExcludeViewFilesFromPublish>
<MvcRazorExcludeRefAssembliesFromPublish Condition="'$(MvcRazorExcludeRefAssembliesFromPublish)'==''">true</MvcRazorExcludeRefAssembliesFromPublish>
</PropertyGroup>

<ItemGroup Condition="'@(MvcRazorFilesToCompile)' == ''">
<MvcRazorFilesToCompile Include="@(Content)" Condition="'%(Extension)'=='.cshtml'" />
</ItemGroup>
</Target>

<Target
Name="MvcRazorPrecompile"
DependsOnTargets="_ResolveInputArguments"
Inputs="@(MvcRazorFilesToCompile);@(IntermediateAssembly);@(DocFileItem);@(_DebugSymbolsIntermediatePath);@(ReferencePath);$(MSBuildAllProjects)"
Outputs="$(_MvcRazorOutputFullPath)">

<CallTarget Targets="_MvcRazorPrecompile" />
</Target>

<Target
Name="_MvcRazorPrecompile"
DependsOnTargets="_RunForCore;_RunForDesktop">

</Target>

<Target
Name="_RunForCore"
DependsOnTargets="_CreateResponseFileForMvcRazorPrecompile"
Condition="'$(TargetFrameworkIdentifier)'=='.NETCoreApp'">

<PropertyGroup>
<_MvcViewCompilationBinaryPath Condition="'$(_MvcViewCompilationBinaryPath)'==''">$(MSBuildThisFileDirectory)$(MSBuildThisFileName).dll</_MvcViewCompilationBinaryPath>

<ExecArgs>dotnet exec --runtimeconfig &quot;$(ProjectRuntimeConfigFilePath)&quot;</ExecArgs>
<ExecArgs>$(ExecArgs) --depsfile &quot;$(ProjectDepsFilePath)&quot;</ExecArgs>
<ExecArgs>$(ExecArgs) &quot;$(_MvcViewCompilationBinaryPath)&quot;</ExecArgs>
<ExecArgs>$(ExecArgs) @&quot;$(_MvcRazorResponseFilePath)&quot;</ExecArgs>
</PropertyGroup>

<Exec Command="$(ExecArgs)" WorkingDirectory="$(MSBuildProjectDirectory)" />
</Target>

<Target
Name="_AddDesktopReferences"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super sure if this works - I have to try creating a mismatch in Mvc versions between the project and the tool which I haven't gotten around to as yet.

AfterTargets="ResolveLockFileReferences"
Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">

<PropertyGroup Condition="'$(_MvcViewCompilationBinaryPath)'==''">
<_MvcViewCompilationBinaryPath Condition="'$(PlatformTarget)'=='x64'">$(MSBuildThisFileDirectory)$(MSBuildThisFileName)-x64.exe</_MvcViewCompilationBinaryPath>
<_MvcViewCompilationBinaryPath Condition="'$(PlatformTarget)'=='x86'">$(MSBuildThisFileDirectory)$(MSBuildThisFileName)-x86.exe</_MvcViewCompilationBinaryPath>
</PropertyGroup>

<ItemGroup Condition="'$(_MvcViewCompilationBinaryPath)'!=''">
<Reference Include="$(_MvcViewCompilationBinaryPath)" Private="true" />
</ItemGroup>
</Target>

<Target
Name="_RunForDesktop"
DependsOnTargets="_AddDesktopReferences;_CreateResponseFileForMvcRazorPrecompile"
Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">

<ItemGroup>
<_PreCompilationFilesToCopy
Include="$(OutputPath)$(AssemblyName).exe.config"
Destination="$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe.config" />

<_PreCompilationFilesToCopy
Include="$(_MvcViewCompilationBinaryPath)"
Destination="$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe" />
</ItemGroup>

<PropertyGroup Condition="'$(MvcRazorRunCommand)'==''">
<MvcRazorRunCommand>$(OutputPath)$(MSBuildThisFileName)-$(PlatformTarget).exe</MvcRazorRunCommand>
</PropertyGroup>

<Copy
SourceFiles="@(_PreCompilationFilesToCopy)"
DestinationFiles="%(Destination)" />

<Exec
Command="&quot;$(MvcRazorRunCommand)&quot; @&quot;$(_MvcRazorResponseFilePath)&quot;"
WorkingDirectory="$(MSBuildProjectDirectory)"/>

<Delete Files="%(_PreCompilationFilesToCopy.Destination)" />
</Target>

<Target Name="_CreateResponseFileForMvcRazorPrecompile">
<ItemGroup>
<_ResponseFileLines Include="
$(MSBuildProjectDirectory);
--output-path=$(_MvcRazorOutputPath);
--application-name=$(AssemblyName);
--content-root=$(MvcRazorContentRoot);" />

<_ResponseFileLines
Condition="'$(MvcRazorEmbedViewSources)'=='true'"
Include="--embed-view-sources" />

<_ResponseFileLines Include="--file=%(MvcRazorFilesToCompile.FullPath)" />
</ItemGroup>

<ItemGroup Condition="'$(SignAssembly)'=='true'">
<_ResponseFileLines
Condition="'$(DelaySign)'=='true'"
Include="--delay-sign" />
<_ResponseFileLines
Condition="'$(PublicSign)'=='true'"
Include="--public-sign" />
<_ResponseFileLines Include="--key-file=$(AssemblyOriginatorKeyFile)" />
</ItemGroup>

<WriteLinesToFile
File="$(_MvcRazorResponseFilePath)"
Lines="@(_ResponseFileLines)"
Overwrite="true" />
</Target>

<Target
Name="_MvcRazorPrecompileOnPublish"
DependsOnTargets="MvcRazorPrecompile"
AfterTargets="PrepareForPublish"
Condition="'$(MvcRazorCompileOnPublish)'=='true'" />

<Target Name="_MvcRazorResolveFilesToCompute"
AfterTargets="ComputeRefAssembliesToPublish"
Condition="'$(MvcRazorCompileOnPublish)'=='true'">

<ItemGroup>
<ResolvedFileToPublish
Remove="%(MvcRazorFilesToCompile.FullPath)"
Condition="'$(MvcRazorExcludeViewFilesFromPublish)'=='true'" />

<ResolvedFileToPublish Include="$(_MvcRazorOutputFullPath)" CopyToPublishDirectory="Always">
<RelativePath>$([System.IO.Path]::GetFileName('$(_MvcRazorOutputFullPath)'))</RelativePath>
</ResolvedFileToPublish>
</ItemGroup>

<ItemGroup Condition="'$(MvcRazorExcludeRefAssembliesFromPublish)'=='true'">
<ResolvedFileToPublish
Remove="%(ResolvedFileToPublish.Identity)"
Condition="'%(ResolvedFileToPublish.RelativePath)'=='$(RefAssembliesFolderName)\%(Filename)%(Extension)'" />
</ItemGroup>
</Target>
</Project>

Loading