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

Add support for pre-compiling desktop applications. #130

Merged
merged 2 commits into from
May 31, 2017
Merged

Conversation

NTaylorMullen
Copy link

  • Disabled net461 tests due to the corefx issue: https://github.com/dotnet/corefx/issues/20364.
  • Manually tested out the desktop pieces on the functional tests and they got to the point where they were exploding for only the corefx issue.
  • Broke out the skipping of tests into its own commit so we can revert it later.

#128

</PropertyGroup>

<ItemGroup>
<None Include="build\**\*" Pack="true" PackagePath="%(Identity)" />
<None Include="buildMultiTargeting\*" Pack="true" PackagePath="%(Identity)" />
<None Include="$(X86ProjectDirectory)\bin\$(Configuration)\net461\win7-x86\$(MSBuildThisFileName)-x86.exe" Pack="true" PackagePath="lib\net461\$(MSBuildThisFileName)-x86.exe" />
Copy link
Author

Choose a reason for hiding this comment

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

@pranavkm The scaffolding guys handle x86 by having their own tool have a x86 RID. Since it's compatible with x64 all just works. Is there a reason why we did this approach for so long?

Leaving as is for now because it's worked in the past; however, these bits would be significantly simpler without the extra project/x86ness.

Choose a reason for hiding this comment

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

I vaguely remember this having to do something with the RID inference during the old project.json days, but not sure.

Having a single executable with x86 makes the size of the nupkg smaller, other than that I am not opinionated about this approach or the one that scaffolding takes.

@NTaylorMullen
Copy link
Author

Note that this wasn't a "just revert an old commit" I had to do most of this stuff manually and rely on tests for confidence. Lots of changes here that have never existed in this repo.

"lib/netcoreapp2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll": "Not a class library. Docs not required for CLI tools"
},
"BUILD_ITEMS_FRAMEWORK": {
"*": "Doesn't matter"
Copy link
Contributor

Choose a reason for hiding this comment

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

:thuglife:

@NTaylorMullen
Copy link
Author

@prafullbhosale could you take a look at this guy to ensure everything looks good?

@@ -16,4 +16,8 @@
<PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkVersion)" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
<PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: PrivateAssets="All"

@@ -0,0 +1,18 @@
<!--
Copyright (c) .NET Foundation. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the copyright header. Per my last conversation about this with @Eilon, we don't put the copyright header into .targets/props files that ship in nuget packages.

<Target
Name="MvcRazorPrecompile"
DependsOnTargets="_ResolveInputArguments"
Inputs="$(MSBuildThisFileFullPath);@(MvcRazorFilesToCompile);@(IntermediateAssembly);@(DocFileItem);@(_DebugSymbolsIntermediatePath);@(ReferencePath);$(MSBuildAllProjects);"
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use MSBuildAllProjects as an input, you should also add this file to that list.

<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>

Example: https://github.com/aspnet/Configuration/blob/cde0c5ed3f0dd1f5bad36633a4c6d1dd7d48d2a9/src/Microsoft.Extensions.Configuration.UserSecrets/build/GenerateUserSecretsAttribute.targets#L4

Copy link
Author

Choose a reason for hiding this comment

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

Hmm? That is in the list; I think I'm misunderstanding your ask.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, let me clarify.

The reason for using MSBuildAllProjects is to invalidate target caches when project files change. If there is anything down stream from this target (i.e. publishing), you should add this file to the MSBuildAllProjects list. This is a best practice when writing incremental build targets that chain into other targets you don't control.

Copy link
Author

Choose a reason for hiding this comment

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

Ahh I gets it now 👍

<CallTarget Targets="_CreateResponseFileForMvcRazorPrecompile" />

<ItemGroup Condition="'$(PlatformTarget)'=='x86'">
<FilesToCopy Include="$(OutputPath)$(AssemblyName).exe.config">
Copy link
Contributor

Choose a reason for hiding this comment

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

FilesToCopy is a fairly generic itemgroup name. My concern is that other targets may populate items into this. If they do, the Copy and Delete tasks below may fail or operation on the wrong files.

To be safe, give it a more specific name (_PreCompilationFilesToCopy) or clear it before using it <FilesToCopy Remove="@(FilesToCopy)" />.

SourceFiles="@(FilesToCopy)"
DestinationFiles="%(Destination)" />

<Message
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove this log message as it doesn't really contain any useful information.

Copy link
Author

Choose a reason for hiding this comment

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

Gonna leave. It's consistent with the already existing netcoreapp2.0 variant.


public ApplicationTestFixture Fixture { get; }

[Fact(Skip = "https://github.com/dotnet/corefx/issues/20364")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be fixed in latest builds of NS.Library.

Copy link
Author

Choose a reason for hiding this comment

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

Not sure why they closed that issue. Still need dotnet/sdk#1259 to be completed before everything works as expected.

@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like every testapp has been updated to multi-target. Do you have any test apps that are only single TFMS? Would be good to keep some of these test cases around as that is the more common scenario.

Copy link
Author

Choose a reason for hiding this comment

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

Yup, SimpleAppDesktopOnly 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

What about just .NET Core (for xplat)?

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, is that something we typically test separately? I can see the value in having 1 single TFM test for tools because of how they're launched but I'm not seeing a reason to have a single targeting TFM for both netcoreapp2.0 and net461.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO there is some value to test all entry points to view compilation. There are three: buildMultiTargeting/ViewCompilation.targets, build/net461/ViewCompilation.targets and build/netcoreapp2.0/ViewCompilation.targets. It's good to ensure all of these work correctly when they are the "entry point" import for view precompilation, aka the outer-build of a project.

Copy link
Contributor

Choose a reason for hiding this comment

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

Previous comments are not relevant now that buildMultiTargeting stuff is gone. Should be fine as is.

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<PreserveCompilationContext>true</PreserveCompilationContext>
Copy link
Contributor

Choose a reason for hiding this comment

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

PreserveCompilationContext and OutputType can be removed. These are already the default values for projects that use Microsoft.NET.Sdk.Web

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having a completely separate project for the x86 version, why not just compile ViewCompilation.csproj multiple times with different configurations? It will reduce the effort required to keep the two csproj files aligned.

Copy link
Author

Choose a reason for hiding this comment

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

Was a bit curious about this one too. Waiting on @pranavkm's feedback on my comment here.

</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'" />
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@NTaylorMullen
Copy link
Author

🆙 📅

@@ -0,0 +1,14 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Copy link
Contributor

@natemcmaster natemcmaster May 30, 2017

Choose a reason for hiding this comment

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

The buildMultiTargeting folder should be moved up a level. It won't land in the right place in the nupkg because this is under build.

@NTaylorMullen
Copy link
Author

🆙 📅

The multi-targeting bits weren't used. Removed them from the system.

Copy link

@prafullbhosale prafullbhosale left a comment

Choose a reason for hiding this comment

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

Over all @natemcmaster's review captures pretty much everything.


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

Choose a reason for hiding this comment

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

This can be simplified by having a default and then overriding if '$(PlatformTarget)'=='x86'

@muratg
Copy link

muratg commented May 30, 2017

👀 Could someone review this please?

@@ -2,12 +2,13 @@
<Import Project="$(MSBuildThisFileDirectory)..\common.targets" />
<PropertyGroup>
<MvcRazorRunCommand>dotnet</MvcRazorRunCommand>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
Copy link
Contributor

Choose a reason for hiding this comment

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

Add to the net461 targets file, too

@NTaylorMullen
Copy link
Author

🆙 📅

@NTaylorMullen
Copy link
Author

Getting this in unless someone objects.

@NTaylorMullen NTaylorMullen force-pushed the nimullen/128 branch 2 times, most recently from 96d97d7 to 883114b Compare May 31, 2017 04:17
@NTaylorMullen NTaylorMullen merged commit 27c6ad4 into dev May 31, 2017
@NTaylorMullen NTaylorMullen deleted the nimullen/128 branch May 31, 2017 05:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants