svenheden / csharp-models-to-typescript

C# models to TypeScript
89 stars 58 forks source link

Net Core 3 support #42

Closed lacroixdavid1 closed 4 years ago

lacroixdavid1 commented 4 years ago

Am I missing something of is it impossible to use this tool using only Net Core 3 installed? I am getting the following output trying to run the code. Huge thanks I appreciate that library.

csharp-models-to-typescript --config=tsgen.config.json

It was not possible to find any compatible framework version

The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.
  - The following frameworks were found:
      3.0.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      3.1.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.
vanilsonbr commented 4 years ago

It seems like you have your project set to use .net core 2.0.0, not 3.1. Check your project.csproj and set the version to 3.1.

I have myself a project running on .net core 3.1 and this lib runs just fine

lacroixdavid1 commented 4 years ago

The problems come form this library csproj file. It still references netcore 2.0. Bumping the net core version in this library csproj file fixes it.

See https://github.com/svenheden/csharp-models-to-typescript/blob/master/lib/csharp-models-to-json/csharp-models-to-json.csproj it still uses net core 2.0.

It probably works on your local setup because it is possible to install multiple net core version to have the ability to build projects using different versions.

Could you please bump your your netcore dependency in the library csproj? My project is using 3.1.

This library was also working fine on my setup until I reformat it and only install net core 3.1. Before formatting, I had both 2.0 and 3.1 installed. I don't want to install net core 2.0 only for this library.

This lib is awesome, I also don't want to fork it only for that reason.

lacroixdavid1 commented 4 years ago

Please merge this PR https://github.com/svenheden/csharp-models-to-typescript/pull/44 and publish on NPM.

vanilsonbr commented 4 years ago

Actually bumping up the version to 3.1 will affect people that have lower SDK versions.

You'll have to find a solution that solves your issue and don't affect other people using the lib, like use .net core standard (which idk if it's possible for this lib, I didn't check all of the dependencies) or detecting the framework version, something along those lines.

AlbertoMonteiro commented 4 years ago

You'll have to find a solution that solves your issue and don't affect other people using the lib, like use .net core standard (which idk if it's possible for this lib, I didn't check all of the dependencies) or detecting the framework version, something along those lines.

@vanilsonbr netstandard target is only used for libraries, for executable we need to target netcoreapp, but instead just changing to new version, we can use multiple targets, in this link there is more details on how to do that https://docs.microsoft.com/pt-br/dotnet/standard/frameworks

lacroixdavid1 commented 4 years ago

I don't want to waste my time on this. Got a solution working locally.