NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

System.Drawing.Common NuGet is not referring System.Runtime NuGet #6336

Closed dillibabun closed 6 years ago

dillibabun commented 6 years ago

After reading the https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcing-the-windows-compatibility-pack-for-net-core/ blog, thought of creating a Image using .NETStandard2.0 using System.Drawing.Common where i have used System.Drawing.FontStyle,StringAlignment etc.. enums.

But facing following compilation errors Error details: 1) error CS0012: The type 'Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 2) error CS0012: The type 'CLSCompliantAttribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

In my Project.Json, i have referred System.Runtime Nuget in which Enum class defined.

My JSON

{ "supports": {}, "dependencies": { "Microsoft.NETCore.Platforms": "2.0.1", "Microsoft.NETCore.Portable.Compatibility": "1.0.1", "Microsoft.Windows.Compatibility": "2.0.0-preview1-25914-04", "NETStandard.Library": "2.0.1", "NETStandard.Library.NETFramework": "2.0.0-preview2-25405-01", "System.Collections": "4.3.0", "System.Diagnostics.Debug": "4.3.0", "System.Drawing.Common": "4.5.0-preview1-25914-04", "System.Drawing.Primitives": "4.3.0", "System.IO": "4.3.0", "System.Reflection.Extensions": "4.3.0", "System.Reflection.TypeExtensions": "4.3.0", "System.Resources.ResourceManager": "4.3.0", "System.Runtime.Extensions": "4.3.0", "System.Runtime.InteropServices": "4.3.0", "System.Runtime.Serialization.Formatters": "4.3.0", "System.Runtime.Serialization.Primitives": "4.3.0", "System.Text.Encoding.Extensions": "4.3.0", "System.Text.RegularExpressions": "4.1.0", "System.Threading": "4.3.0", "System.Xml.ReaderWriter": "4.3.0", "System.Xml.XDocument": "4.3.0" }, "frameworks": { "netstandard2.0": {} }

}

Anyone, please help to resolve this issue ? This is bottleneck for our application.

Thanks in advance, Dilli babu.

dillibabun commented 6 years ago

Can any one look into it ?

mishra14 commented 6 years ago

@dillibabun can you please attach your csproj file?

dillibabun commented 6 years ago

Hi Mishra,

Our csproj is highly confidential so modified them with dummy data.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{84887A73-056A-436F-9F08-86B8D8352D96}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>xxx</RootNamespace>
    <AssemblyName>xxx</AssemblyName>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
    <TargetFrameworkProfile>
    </TargetFrameworkProfile>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\NetStandard20\</OutputPath>
    <DefineConstants>TRACE;DEBUG;NetStandard14;NetStandard20;PORTABLE;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\NetStandard20\</OutputPath>
    <DefineConstants>TRACE;NetStandard14;NetStandard20;PORTABLE;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-Xml|AnyCPU'">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release-Xml\NetStandard20\</OutputPath>
    <DefineConstants>TRACE;PORTABLE;NetStandard14;NetStandard20;</DefineConstants>
    <DocumentationFile>xxx.xml</DocumentationFile>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>

  <ItemGroup>

    <Compile Include="..\..\..\Base\Test1.cs">
      <Link>yyy\xxx\Test1.cs</Link>
    </Compile>
    <Compile Include="..\..\..\Base\Test2.cs">
      <Link>yyy\xxx\Test1.cs</Link>

  </ItemGroup>
  <ItemGroup>
    <None Include="project.json" />
  </ItemGroup>

  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
  <Target Name="BeforeBuild">
    <Copy Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU' Or '$(Configuration)|$(Platform)' == 'Release|AnyCPU' Or '$(Configuration)|$(Platform)' == 'Release-Xml|AnyCPU'" SourceFiles="$(ProjectDir)project20.json" DestinationFiles="$(ProjectDir)project.json">
    </Copy>
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
  <PropertyGroup>
    <PreBuildEvent>copy "$(ProjectDir)project20.json" "$(ProjectDir)project.json" /Y</PreBuildEvent>
  </PropertyGroup>
  <PropertyGroup>
    <NuGetTargetMoniker>.NETStandard,Version=v2.0</NuGetTargetMoniker>
  </PropertyGroup>
</Project>

Regards, Dilli babu.

emgarten commented 6 years ago

netstandard2.0 projects should use csproj with PackageReference.

What version of vs are you using, is there any reason you are still using project.json?

dillibabun commented 6 years ago

We have created a legacy project and then changed the .NETStandard version to 2.0. Can't we achieve this?

emgarten commented 6 years ago

If your target framework is NETStandard2.0 then use the NETCore SDK project style. Not the legacy project style.

mishra14 commented 6 years ago

@dillibabun Please let us know if you are still facing this.