Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix to work with new NuGet PackageReference style in VS2017 #173
One important note. We don't use Custom Tool at cshtml file properties (RazorGenerator) and also we don't use directives at top of cshtml files (
Problem is in RazorGenerator.Core.IsMvcProject method which works only for old NuGet package reference style:
For new one it returns False and thats the problem:
There is easy workaround for this. We just add
PS: RazorVersion: 3 is used for Microsoft.AspNet.Mvc version 5. For version 4 use RazorVersion: 2
I hadn't found the use of razorgenerator.directives, but did see that the detection for Mvc version from the project file was just hunting for the string, not actually parsing the msbuild file in any way.
The suggested workaround using
We have over 200 cshtml files and we are faced with adding
Reporting errors seems to be one at a time, so with over 200 files we would have to recompile over 200 times. It would be better if all errors are reported instead of failing the build as soon as the first error is encountered.
Our project is using areas, so there are more than one root folder for the views. Or can we place
Update: What seems to have worked in our case is adding
As a result we now have a solution that allows us to use
@davidebbo I'd suggest adding this to the readme as it may help others who may be consuming a library that extends from System.Web.Mvc and they may have dropped the direct reference which turns out to be required. I'd posted this on the VS developer-community site as well.