Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code generation fails on ASP.NET Core 3.0 #132

Closed
btihanyi opened this issue Oct 7, 2019 · 2 comments
Closed

Code generation fails on ASP.NET Core 3.0 #132

btihanyi opened this issue Oct 7, 2019 · 2 comments
Labels

Comments

@btihanyi
Copy link

btihanyi commented Oct 7, 2019

I've tested the new release with an ASP.NET Core 3.0 project, but R4MVC throws an error while generating the code. I've also tested with the AspNetSimple.NetCore3 project, but with the same result. Then I checked the source code and found out that the ReferencedAssemblyNames do not contain the Microsoft.AspNetCore.Mvc reference, nor any similar values. So this code

// Get MVC version
var mvcAssembly = compilation.ReferencedAssemblyNames
    .Where(a => a.Name == "Microsoft.AspNetCore.Mvc")
    .FirstOrDefault();

will always assign mvcAssembly a null value for 3.0 projects, then throw a NullReferenceException. I wonder if there is any other way to get the framework's version?

@artiomchi
Copy link
Member

You must have a build error or something, because it detects the reference correctly on all my environments, as well as on the build server.

You can see the latest build log here: https://ci.appveyor.com/project/T4MVC/r4mvc

If you scroll down, you can find this extract:

C:\projects\r4mvc>.\src\R4Mvc.Tools\bin\Release\net472\R4Mvc.Tools.exe generate -p .\samples\AspNetSimple.NetCore3\AspNetSimple.NetCore3.csproj 
  R4Mvc Generator Tool v1.0.0

Using: Visual Studio Community 2019 - 16.3.29326.143
Project: C:\projects\r4mvc\samples\AspNetSimple.NetCore3\AspNetSimple.NetCore3.csproj

Creating Workspace ...
Loading project ...
Compiling project ...
Detected MVC version: 3.0.0.0

Processing controller AspNetSimple.NetCore3.Controllers.HomeController

Generating \Controllers\HomeController.generated.cs
Generating \R4Mvc.generated.cs

Operation completed in 00:00:09.4649861

Are you sure you have the 3.0 SDK installed, and not just the runtime on your machine?

@btihanyi
Copy link
Author

I have installed the full 3.0 SDK with the Visual Studio 2019, however I also have the 2017 version installed on my machine. I've figured out that the R4Mvc tool was using the old Visual Studio instance, but I've managed to specify the proper version via the -vsi command line argument. Now it seems to be working properly.

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

No branches or pull requests

2 participants