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

MSBuild target assumes correct dotnet is on the path #50

Closed
ryanbrandenburg opened this issue Jan 4, 2017 · 9 comments
Closed

MSBuild target assumes correct dotnet is on the path #50

ryanbrandenburg opened this issue Jan 4, 2017 · 9 comments
Assignees
Milestone

Comments

@ryanbrandenburg
Copy link
Contributor

Currently the MSBuild target assumes that the correct dotnet is on the path here. This is not a safe assumption in general, as VS uses a different install of dotnet than the commandline and a couple other instances of weirdness. We should get some more detailed logic in there about finding the correct version.

@pranavkm
Copy link
Contributor

An alternative to running the user process is to use a AssemblyLoadContext \ AppDomain that simulates dotnet exec and run precompilation as part of an MSBuild Task. This would remove the dependency on dotnet (while also addressing bitness issues #47). @natemcmaster has some code that produces a load context from the deps file. Would be nice to POC this early to verify if this is feasible.

cc @DamianEdwards \ @davidfowl since they were discussing this yesterday.

@natemcmaster
Copy link
Contributor

natemcmaster commented Jan 11, 2017

@pranavkm
Copy link
Contributor

@natemcmaster mentioned that this approach (as is our current one) doesn't work with ClassLibraries - blocked due to https://github.com/dotnet/cli/issues/2645. Linking it here so we can follow up on the blocking issue.

@natemcmaster
Copy link
Contributor

Actually, if you are going to try the AssemblyLoadContext approach, the actual blocking bug is this: https://github.com/dotnet/core-setup/issues/635

@pranavkm
Copy link
Contributor

For the 1.1.0-msbuild3 release, there's an MvcRazorRunCommand property that can be overriden to specify the full path to dotnet.exe if it's not in the path.

<PropertyGroup>
  <MvcRazorRunCommand Condition="!$(TargetFramework.StartsWith('netcoreapp'))">$(MSBuildThisFileDirectory)..\.dotnet\dotnet.exe</MvRazorRunCommand>
</PropertyGroup>

The Condition attribute is required only if the application is being multi-targeted.

Similarly, the property can be used to run the precompilation tool using Mono for net451 on a non-Windows OS.

<PropertyGroup>
  <MvcRazorRunCommand Condition="'$(OS)'!='Windows_NT'">mono $(MvcRazorRunCommand)</MvRazorRunCommand>
</PropertyGroup>

@mikeharder
Copy link
Contributor

mikeharder commented Jun 19, 2017

@Eilon: Should this be considered for preview2? Does this bug mean the CLI zip installer cannot be used with MVC apps? If so, this seems like a major issue.

@mikeharder
Copy link
Contributor

Or add the issue and workaround to a readme or similar docs for Preview2.

@pranavkm
Copy link
Contributor

@mikeharder we've had this issue since the 1.0.0 of the tool, so I'm not entirely sure it would warrant requiring a preview2 fix. The msbuild task assumes dotnet.exe is in the path, and the workaround has been to either add it to the path or specify it via an MSBuild property MvcRazorRunCommand.

@pranavkm
Copy link
Contributor

Using MSBuild's muxer if available as part of fe4cc97. We can look running the tool in-proc if we get further issues about this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants