OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.49k stars 6.5k forks source link

[BUG] [csharp-netcore] <TargetFrameworkIdentifier> Must Be '.NETPortable' #3155

Open RugerSR9 opened 5 years ago

RugerSR9 commented 5 years ago

I keep encountering an issue when creating a csharp-netcore client API for ShipEngine. I have been unable to find a fix.

It seems the ProjectTypeGuids is making the project be noticed as a .NETPortable project rather than a .NETStandard project even though the TargetFrameworkIdentifier is .NETStandard.

I have tried removing the ProjectTypeGuids which breaks the project further. Changing the TargetFrameworkIdentifier to .NETStandard does not resolve the issue either.

Edit: I am using Visual Studio 2017 on Windows 10.

Edit 2: The exact error message is

The project file 'Org.OpenApiTools' cannot be opened.

The <TargetFrameworkIdentifier> for a portable project must be '.NETPortable'.

Complete .csproj:

<?xml version="1.0" encoding="utf-8"?>
<!--
ShipEngine API

ShipEngine is the world's best multi-carrier shipping API, with more than 20 supported shipping carriers.  You can easily get and compare shipping rates, print labels, track your shipments, and validate addresses anywhere in the world.  ### Worldwide Major Carrier Support Access the top global carriers in minutes—instead of weeks. Simply [connect your existing carrier accounts](https://docs.shipengine.com/docs/setup-a-carrier) in the API dashboard, and then [begin creating labels](https://docs.shipengine.com/docs/use-a-specific-service).  ### Real-Time Tracking [Track packages](https://docs.shipengine.com/docs/track-a-package) across any of our 20+ supported carrier accounts and create tracking events to keep your customers up-to-date. Easily integrate real-time tracking information for shipments into your app, email, or SMS.  ### Get Rates Across Carriers Make sure you ship as cost-effectively as possible by [quickly comparing rates](https://docs.shipengine.com/docs/get-shipping-rates) using the ShipEngine Rates API. As long as you have the carrier connected to your account, you'll be able to see and compare different rates and services.  ### Global Address Validation No matter your shipping volume, failed deliveries and address change surcharges cut into your bottom line and damage perception with customers. Our address validation services ensure your packages make it to the right place the first time. [Learn how to leverage our address validation services here.](https://docs.shipengine.com/docs/address-validation)  ShipEngine supports address validation for over 180 countries, including the United States, Canada, Great Britain, Australia, Germany, France, Norway, Spain, Sweden, Israel, Italy, and more. 

The version of the OpenAPI document: 1.0.0
Contact: sales@shipengine.com
-->
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
  <PropertyGroup>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{321F1932-4D03-4337-9132-7D0DA8AD230B}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Org.OpenAPITools</RootNamespace>
    <AssemblyName>Org.OpenAPITools</AssemblyName>

    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
    <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
    <FileAlignment>512</FileAlignment>
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
    <OldToolsVersion>15.0</OldToolsVersion>
  </PropertyGroup>
  <ItemGroup>
    <!-- A reference to the entire .NET Framework is automatically included -->
    <None Include="project.json" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="CompareNETObjects" Version="4.57.0" />
    <PackageReference Include="JsonSubTypes" Version="1.5.2" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
    <PackageReference Include="RestSharp" Version="106.6.7" />
    <PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />
  </ItemGroup>
  <Import Project="..\..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
</Project>

Any ideas?

li1515 commented 5 years ago

I haven't found why it generated wrong .csproj file, but it works with .NET Core target:

   <TargetFramework>netcoreapp2.0</TargetFramework>
   <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
   <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
RugerSR9 commented 5 years ago

Thanks @li1515

That manual fix seems to work. I am going to leave this open as it actually seems to be a bug. A mod can close it if they feel that it is necessary.