_From @shai-glat on February 21, 2019 12:44_
<PropertyGroup>
<NuspecFile>nuspec\MyProj.nuspec</NuspecFile>
</PropertyGroup>
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>
dotnet pack MyProj.csproj -o out /p:Version=1.0.1Generated package is a valid .NET Core package
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
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]
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_
Any news on this issue? been over a week since it was posted here and heard nothing on the subject.
Can you please explain the scenario of why you're trying this? We might be able to give a better answer.
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.
dlls should go under lib/tfm directories, not just lib.
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
@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>
Most helpful comment
@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
Expected/Needed