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

C# generated code should use ASP.NET core project structure #2886

Closed
kbrooks opened this issue May 16, 2016 · 25 comments
Closed

C# generated code should use ASP.NET core project structure #2886

kbrooks opened this issue May 16, 2016 · 25 comments

Comments

@kbrooks
Copy link
Contributor

kbrooks commented May 16, 2016

We should add an option to the csharp generator to use the new ASP.NET core project structure.

@wing328

@wing328
Copy link
Contributor

wing328 commented May 17, 2016

@kbrooks thanks for the suggestion. Is there any official guide from MS on the ASP.NET core project structure?

I did a search and found this: http://zablo.net/blog/post/modular-asp-net-core-project-structure (which is not official)

Also to be clear, you're referring to C# API client but not ASP.NET5 server stub, right?

Recently, there's a change to the folder structure via #2752 so please pull the latest master and give it a try if you've not done so.

@kbrooks
Copy link
Contributor Author

kbrooks commented May 17, 2016

The official docs appear to be down right now, but in case they come back up: https://docs.asp.net/en/latest/conceptual-overview/understanding-aspnet5-apps.html.

The main difference is the use of project.json files instead of the old xml configuration files.
The new project structure will be useful to anyone developing on mono or .NET core.

The ASP.NET5 server stub actually already uses the ASP.NET core project structure, so we could use that as a guide.

@wing328
Copy link
Contributor

wing328 commented May 17, 2016

Yup, I got a 404. Will check it out later.

@jimschubert
Copy link
Contributor

@kbrooks @wing328 I'd put this on the back burner for now. There's talk of dropping the project.json and moving back to MSBuild based .csproj after RC2.

See: https://twitter.com/davidfowl/status/730219570783363073 and https://youtu.be/P9HqMZviaMg?t=1712. There was also a pretty lengthy discussion on Reddit about a week ago.

Since Xamarin Studio is free to use on OS X and Linux and Visual Studio Community Edition is also free to use, there's nothing blocking anyone from developing on mono on any OS. Both of these support targeting current .NET 4.6.1.

The only thing this blocks is from consuming .NET Core assemblies, which I think would be fairly minor to incorporate after all the csproj stuff dies down.

@kdc415
Copy link

kdc415 commented Jun 1, 2016

Looks like MS says they're going back to MSBuild

https://blogs.msdn.microsoft.com/dotnet/2016/05/23/changes-to-project-json/

I've just downloaded my first swagger generated api server stub. I downloaded core RC1 to try to run it and it hosed my VS 2015 installation.

Then I found this article, so I decided to make a new MVC5 project and incorporate the models/controllers and I'm having some trouble. Is there an example/tutorial out there somewhere? I've looked to no avail.

Thx - Ken

@jimschubert
Copy link
Contributor

@kdc415 You should be able to run .NET Core RC1 and RC2/RTM side by side. I'm not sure why it would hose your environment.

When I created the aspnet5 server generator, I created two examples here https://github.com/jimschubert/webapi-swagger-samples. The netstandard-1.4 directory is what became the generator while the net45/src stuff is Web API 5.2.3 code. I didn't create a generator for the older MVC code because it would quickly become outdated.

You should be able to develop against the generated code, and run in Docker if your local RC1 install is messed up.

docker build --name myapp .
docker run -v .:/app/proj -w /app/proj myapp

The app should be available now on port 5000. To get the ip address of the myapp container, run:

docker inspect --format '{{ .NetworkSettings.IPAddress }}' myapp

@kdc415
Copy link

kdc415 commented Jun 2, 2016

Thanks for the response and the advice - I'll give it a shot. This is a new project and I suppose I may as well bite the bullet and use the latest. I expect we'll see final release very soon.

@stunney
Copy link
Contributor

stunney commented Jun 23, 2016

I know a lot of you are talking about this work being put on hold. For those that care I'm currently doing some work on this in stunney/swagger-codegen. I'll be making a PR soon :)

@jimschubert
Copy link
Contributor

@stunney I checked your master branch and the work being done there doesn't look relevant to this issue.

The issue was to use the new project structure for ASP.NET Core for C# generators. As stated above, the aspnet5 generator is already set up this way. The client generators aren't candidates for this because they target .NET 3.5 and 4.0-4.5.

The issue was updated a few comments later to clarify the request was to use the project.json build, which is deprecated.

The reason I say your master branch doesn't seem relevant is it looks like you're trying to update aspnet5 to RC2. As stated in another issue, the final release is slated for June 27, so it doesn't make a lot of sense to update the current RC1 generator to RC2 now. Also aspnet5 should probably be updated to 1.0 RTM/Final in place rather than creating another generator.

If you'd like to honcho that effort, let me know and I can comment in the other thread that you've got dibs.

@stunney
Copy link
Contributor

stunney commented Jun 23, 2016

I can honcho that effort for sure :)
I've created a new "language" for this effort so that folks that still need RC1 for existing projects can still get at it without me interfering with them. Some backwards compatibility is always a good thing. Also, aspnet5 won't be a valid name anymore as they are calling it aspnet core 1.0, correct? I was going to call it aspnetcore1.

I haven't checked it in yet, but I'm working on an msbuild moustache as well as the project.json file. Maybe I don't need both as per the discussions above. I can nix the json file :)

@jimschubert
Copy link
Contributor

jimschubert commented Jun 23, 2016

@stunney You bring up good points ;)

I've already accounted for the name change (via discussion only atm) in #3085. My suggestion for the name change was to have a top level generator called aspnet and have library options like core-1.0rc1, core-1.0rc2, etc. This way we could also have MVC 4/5 templates and it wouldn't be confusing about how to find the generators and it wouldn't clutter the list of available server generators.

However, I don't think it would be beneficial from an open source community perspective to continue maintaining many separate 1.0x generators. If anyone needs 1.0rc1, it's available in version 2.1.6 of the generator. 1.0rc2 is honestly not that much different from rc1.

Also, I have a few cleanup/include tasks in #2914 for the existing generator. If you're modeling your update after the current code, those are a few things that are missing.

@stunney
Copy link
Contributor

stunney commented Jun 24, 2016

Looking to moustache-ize the .xproj file
Does anyone know how to generate a new UUID from moustache? My googling has come up blank. Would I have to write a custom javascript block at the top of this moustache file? I can't be the first person to hit this :(

@jimschubert
Copy link
Contributor

There's already support for project guid on the csharp generator.

@stunney
Copy link
Contributor

stunney commented Jun 27, 2016

Blarg @jimschubert
I feel silly. Thanks for that smack, I deserve it.

@stunney
Copy link
Contributor

stunney commented Jun 27, 2016

{{packageGuid}}

Its so simple :)

@ogreenz
Copy link

ogreenz commented Dec 5, 2016

I don't know if I should reply here / start an issue. So basically project.json is a dead horse and in VS 2017 RC ASP.NET Core projects are created with a .csproj any chance there will be porting for that convention?

@wing328
Copy link
Contributor

wing328 commented Dec 5, 2016

@ogreenz I would suggest you to open a new issue for tracking and link to this one.

@jimschubert
Copy link
Contributor

We'll want this behind a flag (even if it's the new default behavior), because not all devs track on the latest Visual Studio. I was waiting until general availability before doing an update, because the .NET Core stuff is known to change on a dime.

@ogreenz
Copy link

ogreenz commented Dec 5, 2016

@jimschubert Well to be honest swagger kind of "forced" me to used the latest .NET Core stuff when it deprecated the .csproj in favor of the project.json. And because I have in my solution "old" .csproj projects, they don't like to play together and make my life harder. So now I'm transitioning into the "new" .csproj in the hopes that it will resolve my issues. But I completely understand and agree with you on the .NET Core stuff changing on a dime, believe me I'm no happy user when standards keep on changing every few months.
@wing328 will do, even if you don't get to it right away I think it would be inevitable in the future anyway.

@knom
Copy link
Contributor

knom commented Dec 2, 2017

Are you planning to change to .NET Core 2.0 in the next version?
Happy to help!

@jimschubert
Copy link
Contributor

I personally would like to move to .net core 2 for Swagger Codegen 2.3.

The issue with making the change before 2.3 is that it would be confusing if you've customized templates to have different (or missing) templates and configurations.

@wing328
Copy link
Contributor

wing328 commented Dec 13, 2017

#7114 BY @knom has been merged into master.

For those who need .NET core 2.0 support, please pull the latest master to give it a try.

@knom
Copy link
Contributor

knom commented Jun 24, 2018

@wing328 Should this be closed?

@stunney
Copy link
Contributor

stunney commented Jun 25, 2018

+1 to closing this ancient issue.

@mdmota
Copy link

mdmota commented May 2, 2019

any prediction to launch client for asp.net core with dependency injection?
the constructor api is giving new in restsharp.
I tested with CsharpDotnett2

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

No branches or pull requests

9 participants