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

Creating nuget package using dotnet pack command and <NuspecFile> tag creates a package targeting .Net Framework #7825

Open
livarcocc opened this issue Feb 24, 2019 · 4 comments
Labels
Functionality:Pack Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:dotnet.exe
Milestone

Comments

@livarcocc
Copy link

From @shai-glat on February 21, 2019 12:44

Steps to reproduce

  1. Create a csproj and generated a nuget package from it - works as expected
  2. Open the package and take out the generated nuspec file.
  3. Add the following tag to csproj:
    <PropertyGroup> <NuspecFile>nuspec\MyProj.nuspec</NuspecFile> </PropertyGroup>
  4. Add the files tag to nuspec file as follows:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
..... (unmodified)
  </metadata>
	<files>
		<file src="<Path>/MyProj.dll" target="lib" />
		<file src="<Path>/OtherFile.dll" target="lib" />
	</files>
</package>
  1. run dotnet pack MyProj.csproj -o out /p:Version=1.0.1

Expected behavior

Generated package is a valid .NET Core package

Actual behavior

Package contents are all .NET Core dlls, but when adding the package visual studio it states the package was restored using .NetFramework 4.6 instead of .Net Core 2.1

Environment data

dotnet --info output:
.NET Core SDK (reflecting any global.json):
Version: 2.2.101
Commit: 236713b0b7

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.101\

Host (useful for support):
Version: 2.2.0
Commit: 1249f08fed

.NET Core SDKs installed:
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.2.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Additional notes

I had the same problem when adding NuspecFile via dotnet CLI, as well as when i started with an empty nuspec file and simply added the files tag as stated above

Copied from original issue: dotnet/cli#10861

@shai-glat
Copy link

Any news on this issue? been over a week since it was posted here and heard nothing on the subject.

@zivkan
Copy link
Member

zivkan commented Mar 7, 2019

Can you please explain the scenario of why you're trying this? We might be able to give a better answer.

  1. It shouldn't be necessary to use a nuspec file. I'm only aware of a single NuGet metadata (lang) that can't be specified in the csproj. Otherwise I believe everything that can be done in a nuspec can be done in the csproj. In your case, look for PackagePath in these docs.

  2. dlls should go under lib/tfm directories, not just lib.

@shai-glat
Copy link

What i am trying to achieve is to include an internal dependency DLL in the package i am generating, so that i don't have to release it as a separate package.
Ideally (and i am aware this is not possible at the moment) i'd like to mark this internal DLL so that its dependencies are added as package dependencies. To get past this issue i've tried using the nuspec file to define the package, but i keep getting a .Net Framework package.

i haven't tried #1, although i'm not sure it will solve my problem (adding a nuspec file caused the package and i have a feeling any nuget-related tags in csproj)
regarding #2, dotnet tool's nuget spec creates a package with all the libraries under lib instead of lib/tfm

@johnwc
Copy link

johnwc commented May 17, 2019

@zivkan There is one scenario that I am not able to do in the CSPROJ file, and that is set the dependencies of the project to not be grouped per target framework.

Explanation of what I am doing to help understand why I need this
I use VS SDK project to create chocolatey packages, which are nothing more than a Nuget package. I've added chocolatey's nuget repo in VS, and I am able to add dependencies to the project using the built-in Nuget Manager. Everything works a charm, except when the packages get built, it groups all the dependency packages as target framework .Net Standard2.0. Because of this, I have to set the NuspecFile value in the CSPROJ file.

Actual

<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    …
    <dependencies>
      <group targetFramework=".NETStandard2.0">
        <dependency id="chocolatey-core.extension" version="1.3.3" />
      </group>
    </dependencies>
  </metadata>
</package>

Expected/Needed

<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    …
    <dependencies>
      <dependency id="chocolatey-core.extension" version="1.3.3" />
    </dependencies>
  </metadata>
</package>

@jeffkl jeffkl added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. and removed Pipeline:Icebox labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Pack Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:dotnet.exe
Projects
None yet
Development

No branches or pull requests

8 participants