Today I tried to update my netstandard2.0 class library and got a warning that the <PackageLicenseUrl> element is deprecated. After doing some research, I added the following lines to my csproj file:
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<!-- .... -->
<ItemGroup>
<None Include="..\LICENSE.txt" Pack="true" PackagePath="$(PackageLicenseFile)"/>
</ItemGroup>
Later, I tried to publish the package. dotnet pack runs without issue, but for dotnet nuget push xxx.1.0.2.nupkg -k xxx -s https://api.nuget.org/v3/index.json prints the following error:
info : "xxx.1.0.2.nupkg" wird per Push nach "'https://www.nuget.org/api/v2/package'" übertragen...
info : PUT https://www.nuget.org/api/v2/package/
warn : Your API key expires in 1 days. Visit https://www.nuget.org/account/apikeys to regenerate your API key.
info : BadRequest https://www.nuget.org/api/v2/package/ 1661 ms
error: Response status code does not indicate success: 400 (License files are not yet supported.).
Summary:
PackageLicenseUrl is deprecated but works
PackageLicenseFile is not implemented
Did I miss something?
The new NuGet client shipped before the NuGetGallery depolyed support for the feature. But it should be coming very soon. If you use a well known license, you can use the SDPX expression instead, and nuget.org will accept those already.
EDIT: nuget.org is now accepting packages with licence file. Announcement of the new licence feature here.
Related
My %userprofile%\appdata\Roaming\nuget\NuGet.Config contains:
<configuration>
<packageSources>
<add key="rt1" value="https://my-server.com/artifactory/api/nuget/nuget-local" />
<add key="rt2" value="https://my-server.com/artifactory/api/nuget/nuget-local/rt2" />
</packageSources>
Now push works for both, but install works only with rt1.
nuget push My.Package.1.0.0.nupkg -source rt1 # works
nuget push My.Package.1.0.0.nupkg -source rt2 # works
nuget install My.Package # DOES NOT WORK IF I HAVE rt2 as source
OK https://my-server.com/artifactory/api/nuget/nuget-local/FindPackagesById()?id='My.Package'&semVerLevel=2.0.0 154ms
An error occurred while retrieving package metadata for 'My.Package' from source 'rt2'.
Failed to fetch results from V2 feed at 'https://my-server.com/artifactory/api/nuget/nuget-local/rt2/FindPackagesById()?id='My.Package'&semVerLevel=2.0.0' with following message : Response status code does not indicate success: 405 (Method Not Allowed).
Response status code does not indicate success: 405 (Method Not Allowed).
Is this expected behavior? It looks like nuget expects FindPackagesById() to be available on repo url for install operation, and it is failing on rt2.
Is there any way to use the path as a source, without creating virtual repo with Includes/Excludes config? Would jfrog nuget cli give me different behavior?
I found it was also asked in jfrog: https://www.jfrog.com/jira/browse/RTFACT-23310, but it was marked as Not a Bug without any explanation.
Someone filed an issue with Artifactory/JFrog and they closed it as "Not a Bug": https://www.jfrog.com/jira/browse/RTFACT-23310
So apparently using package paths is not supported when pulling from Artifactory as a nuget source (even though it is supported when pushing).
I'm trying to upload a new NuGet package on the website.
https://www.nuget.org/packages/manage/upload
On the first attemp I received an error that says I need to specify the license.
I don't want but... ok.
So, my first attempt with a specified license failed. I read the linked documentation and I tried multiple times.
I tried with a <license> property and also including a license.txt file in the package.
These are my try with the .nuspec file and the error I receive:
<license type="MIT"/>
=> Error: Unsupported license type 'MIT'.
(I know it is wrong but I found this "example" here: https://github.com/NuGet/Home/wiki/Packaging-License-within-the-nupkg)
<license type="expression">MIT</license>
=> Error: To provide a better experience for older clients when a license expression is specified, must be set to 'https://licenses.nuget.org/MIT'.
<license type="expression">BSD-2-Clause OR MIT</license>
=> Error: To provide a better experience for older clients when a license expression is specified, must be set to 'https://licenses.nuget.org/BSD-2-Clause%20OR%20MIT'.
<license type="expression">https://licenses.nuget.org/MIT</license>
=> Error: Invalid license metadata: The license expression 'https://licenses.nuget.org/MIT' contains invalid characters.
I also tried with my license.txt without success.
What I'm doing exactly is: modify the mylibrary.nuspec file contained in a generated mylibrary.nupkg adding the <license> field.
Why? Because this VS studio project generatse the package using nuget.exe mylibrary.csproj file, and it does not contains the license.
I updated nuget.exe to the latest 5.1 version, but I don't want to modify the VS solution or project.
Any idea ?
Edit the .csproj file. Add the following:
Using License file:
<PropertyGroup>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
<None Include="licenses\LICENSE.txt" Pack="true"
PackagePath="LICENSE.txt"/>
</ItemGroup>
Using PackageLicenseExpression:
<PropertyGroup>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
For more details, see
In my case I had to set two properties:
PackageLicenseUrl - https://licenses.nuget.org/MIT
PackageLicenseExpression - MIT
We are currently using SyncFusion for our solution at work for one of our solutions. In local every package are restoring but in VSTS it seem that it's having some difficulties to mix both syncfusion packages with official nuget packages.
I posted the entire log of the nuget restore on a gist here : https://gist.github.com/erickgirard/844f57d0f98f0cbea13d6ad4ddbde7e0
What I believe is that for every package in packages.config it's trying all sources (is there a possibility to specify a source for one package?)
Not quite sure of what are the solution here beside commiting the syncfusion dlls in the source control.
Here is the nuget.config file of the solution:
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="sync fusion nuget feed" value="http://nuget.syncfusion.com/aspnetmvc" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
</packageRestore>
</configuration>
Here is an excerpt of the logs:
[...]
2017-10-16T16:10:33.6063822Z Acquiring lock for the installation of Swashbuckle.Core 5.5.3
2017-10-16T16:10:33.6123760Z Acquired lock for the installation of Swashbuckle.Core 5.5.3
2017-10-16T16:10:33.6123760Z Installing Swashbuckle.Core 5.5.3.
2017-10-16T16:10:33.6173723Z NotFound http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/Packages(Id='System.IdentityModel.Tokens.Jwt',Version='5.1.4') 97ms
2017-10-16T16:10:33.6173723Z GET http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/FindPackagesById()?id='System.IdentityModel.Tokens.Jwt'
2017-10-16T16:10:33.6453473Z NotFound http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/Packages(Id='Microsoft.Net.Compilers',Version='2.2.0') 562ms
2017-10-16T16:10:33.6453473Z GET http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/FindPackagesById()?id='Microsoft.Net.Compilers'
2017-10-16T16:10:33.6913056Z OK https://api.nuget.org/v3-flatcontainer/system.identitymodel.tokens.jwt/5.1.4/system.identitymodel.tokens.jwt.5.1.4.nupkg 143ms
2017-10-16T16:10:33.6913056Z Acquiring lock for the installation of System.IdentityModel.Tokens.Jwt 5.1.4
2017-10-16T16:10:33.6923050Z Acquired lock for the installation of System.IdentityModel.Tokens.Jwt 5.1.4
2017-10-16T16:10:33.6923050Z Installing System.IdentityModel.Tokens.Jwt 5.1.4.
2017-10-16T16:10:33.6923050Z NotFound http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/Packages(Id='Unity.AspNet.WebApi',Version='4.0.1') 103ms
2017-10-16T16:10:33.6923050Z GET http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/FindPackagesById()?id='Unity.AspNet.WebApi'
2017-10-16T16:10:33.6943020Z OK http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/FindPackagesById()?id='Microsoft.Net.Compilers' 49ms
2017-10-16T16:10:33.7092888Z OK http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/FindPackagesById()?id='Unity.AspNet.WebApi' 44ms
2017-10-16T16:10:33.7312690Z OK https://api.nuget.org/v3-flatcontainer/unity.aspnet.webapi/4.0.1/unity.aspnet.webapi.4.0.1.nupkg 170ms
[...]
2017-10-16T16:10:41.1345069Z Completed installation of System.IdentityModel.Tokens.Jwt 5.1.4
2017-10-16T16:10:41.1395038Z Adding package 'System.IdentityModel.Tokens.Jwt.5.1.4' to folder 'd:\a\3\s\Projets\packages'
2017-10-16T16:10:41.1425014Z Added package 'System.IdentityModel.Tokens.Jwt.5.1.4' to folder 'd:\a\3\s\Projets\packages'
2017-10-16T16:10:41.1455002Z Added package 'System.IdentityModel.Tokens.Jwt.5.1.4' to folder 'd:\a\3\s\Projets\packages' from source 'https://api.nuget.org/v3/index.json'
2017-10-16T16:10:41.3558804Z Completed installation of Swashbuckle.Core 5.5.3
2017-10-16T16:10:41.3578871Z Completed installation of Microsoft.TeamFoundationServer.Client 15.115.0-preview
2017-10-16T16:10:41.3578871Z Adding package 'Microsoft.TeamFoundationServer.Client.15.115.0-preview' to folder 'd:\a\3\s\Projets\packages'
2017-10-16T16:10:41.3588793Z Adding package 'Swashbuckle.Core.5.5.3' to folder 'd:\a\3\s\Projets\packages'
2017-10-16T16:10:41.4116910Z Added package 'Swashbuckle.Core.5.5.3' to folder 'd:\a\3\s\Projets\packages'
2017-10-16T16:10:41.4116910Z Added package 'Swashbuckle.Core.5.5.3' to folder 'd:\a\3\s\Projets\packages' from source 'https://api.nuget.org/v3/index.json'
2017-10-16T16:10:41.4116910Z Added package 'Swashbuckle.Core.5.5.3' to folder 'd:\a\3\s\Projets\packages'
2017-10-16T16:10:41.4116910Z Added package 'Swashbuckle.Core.5.5.3' to folder 'd:\a\3\s\Projets\packages' from source 'https://api.nuget.org/v3/index.json'
[...]
2017-10-16T16:10:56.8833741Z Running restore with 2 concurrent jobs.
2017-10-16T16:10:56.8853733Z Reading project file d:\a\3\s\Projets\DobermanHub.GFI.Functions\DobermanHub.GFI.Functions.csproj.
2017-10-16T16:10:56.9003673Z Restoring packages for d:\a\3\s\Projets\DobermanHub.GFI.Functions\DobermanHub.GFI.Functions.csproj...
2017-10-16T16:10:56.9153620Z Restoring packages for .NETFramework,Version=v4.6.1...
2017-10-16T16:10:57.0043336Z GET http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'
2017-10-16T16:10:57.0203252Z GET https://api.nuget.org/v3-flatcontainer/microsoft.net.sdk.functions/index.json
2017-10-16T16:10:57.0992975Z OK https://api.nuget.org/v3-flatcontainer/microsoft.net.sdk.functions/index.json 85ms
2017-10-16T16:10:57.1122942Z InternalServerError http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions' 111ms
2017-10-16T16:10:57.1162923Z Retrying 'FindPackagesByIdAsyncCore' for source 'http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions''.
2017-10-16T16:10:57.1162923Z Response status code does not indicate success: 500 (Internal Server Error).
2017-10-16T16:10:57.1162923Z GET http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'
2017-10-16T16:10:57.1332855Z GET https://api.nuget.org/v3-flatcontainer/microsoft.net.sdk.functions/1.0.2/microsoft.net.sdk.functions.1.0.2.nupkg
2017-10-16T16:10:57.1442827Z OK https://api.nuget.org/v3-flatcontainer/microsoft.net.sdk.functions/1.0.2/microsoft.net.sdk.functions.1.0.2.nupkg 10ms
2017-10-16T16:10:57.1762708Z InternalServerError http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions' 59ms
2017-10-16T16:10:57.1762708Z Retrying 'FindPackagesByIdAsyncCore' for source 'http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions''.
2017-10-16T16:10:57.1762708Z Response status code does not indicate success: 500 (Internal Server Error).
2017-10-16T16:10:57.1762708Z GET http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'
2017-10-16T16:10:57.3411621Z InternalServerError http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions' 165ms
2017-10-16T16:10:59.6996347Z System.AggregateException: One or more errors occurred. ---> NuGet.Protocol.Core.Types.FatalProtocolException: Failed to retrieve information about 'Microsoft.NET.Sdk.Functions' from remote source 'http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id='Microsoft.NET.Sdk.Functions''. ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
2017-10-16T16:10:59.6996347Z at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
2017-10-16T16:10:59.6996347Z at NuGet.Protocol.HttpSource.<>c__DisplayClass12_0`1.<<GetAsync>b__0>d.MoveNext()
2017-10-16T16:10:59.6996347Z --- End of stack trace from previous location where exception was thrown ---
2017-10-16T16:10:59.7006128Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2017-10-16T16:10:59.7006128Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2017-10-16T16:10:59.7006128Z at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__2`1.MoveNext()
In our NuGet Server, we are maintaining multiple Feeds based on platforms and in NuGet site we are displaying friendly feed URLs. If you copy and paste those friendly URLs in any browser, it will redirect to actual Feed Link.
Friendly Feed URL:
http://nuget.syncfusion.com/aspnetmvc/
Actual Feed URL:
http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/
Your given below URL is incorrect hence it’s return 500 error while resorting the ASPNET MVC package.
http://nuget.syncfusion.com/aspnetmvc/FindPackagesById()?id=%27Microsoft.NET.Sdk.Functions%27
In your case, you must use actual feed URL instead of friendly URL.
http://nuget.syncfusion.com/nuget_aspnetmvc/nuget/getsyncfusionpackages/aspnetmvc/FindPackagesById()?id=%27Microsoft.NET.Sdk.Functions%27
Please follow the steps given in the below link.
https://www.syncfusion.com/kb/7609/how-to-install-syncfusion-nuget-packages-in-visual-studio-2017
Thanks,
Mathan Kumar
I'd like to restore the nuget packages from a private feed (vsts internal feed) in a solution consisting of msbuild 15 projects, and subsequently build (and pack) the projects.
I'm using the VS 2017 hosted agent which I need to build.
I've tried restoring with msbuild with (the deprecated) package restore enabled. This results in no packages being restored. The relevant part of the logs:
2017-04-03T12:21:23.5543508Z ##[warning]The 'Restore NuGet Packages' option is deprecated. To restore NuGet packages in your build, add a NuGet Installer task to your build definition.
2017-04-03T12:21:23.5803410Z ##[command]"C:\LR\MMS\Services\mms\TaskAgentProvisioner\Tools\agents\2.115.0\externals\nuget\NuGet.exe" restore "C:\a\1\s\mysolution.sln" -NonInteractive
2017-04-03T12:21:24.5231560Z MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework\v4.0.30319'.
I've tried restoring with the nuget installer task. This fails with
2017-04-03T12:21:05.3231625Z [command]C:\a_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe restore -NonInteractive C:\a\1\s\mysolution.sln -Verbosity Detailed -msbuildversion 15
2017-04-03T12:21:07.5100892Z NuGet Version: 3.5.0.1938
2017-04-03T12:21:07.8293660Z System.AggregateException: One or more errors occurred.
---> NuGet.CommandLine.CommandLineException: Failed to load msbuild Toolset
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
note that I pass in msbuildversion -15 as additional argument, but it seems nuget tries to load msbuild 14.
I've tried restoring with the dontnet cli dotnet restore. This fails with
2017-04-03T12:21:08.3424716Z [command]C:\Program Files\dotnet\dotnet.exe restore C:\a\1\s\path\to\my\csproj
2017-04-03T12:21:12.8146350Z Restoring packages for C:\a\1\s\path\to\my\csproj...
2017-04-03T12:21:12.8146350Z C:\Program Files\dotnet\sdk\1.0.0\NuGet.targets(97,5): error : Unable to load the service index for source https://myvstsaccount.pkgs.visualstudio.com/_packaging/Toolsfeed/nuget/v3/index.json. [C:\a\1\s\path\to\my\csproj]
2017-04-03T12:21:12.8146350Z C:\Program Files\dotnet\sdk\1.0.0\NuGet.targets(97,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\a\1\s\path\to\my\csproj]
2017-04-03T12:21:12.8176375Z ##[error]Dotnet command failed with non-zero exit code: 1.
The nuget.config in my solution directory is
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="VSTS Tools Feed" value="https://myvstsaccount.pkgs.visualstudio.com/_packaging/Toolsfeed/nuget/v3/index.json" />
</packageSources>
<apikeys>
<add key="https://myvstsaccount.pkgs.visualstudio.com/_packaging/Toolsfeed/nuget/v3/index.json" value="<A PAT generated from an account with access to the feed>" />
</apikeys>
</configuration>
and the logs of the tasks show that the config is used.
Locally package restore works fine from VS, or with the nuget cli of nuget 4.0.
What task should I use to restore packages for msbuild 15 projects, and how can I configure authentication?
Restoring nuget packages defined as PackageReference elements in csproj project definitions requires nuget 4.0, which isn't included on the hosted build agents.
You can work around this restriction by including the nuget 4.0 binary in your source control tree, and referring to that binary within the package restore task as a custom NuGet version.
For example, when you include the nuget 4.0 binary in a file called nuget4.0.exe in the root directory of your source tree, you can specify the path as $(Build.SourcesDirectory)/nuget4.0.exe.
And there is a relate question here for you to refer.
My package builds successfully and is uploaded to the Packages feed in VSTS however I can't seem to figure out how to edit the Description and Author of the package so that my set values show in the Package feed.
From what I read I put my content in the NuGet Packager under additional build properties and when I look at the log file I see this:
...NuGet.exe pack "...csproj" -OutputDirectory "..." -Properties Configuration=release;Description="My Description";Authors="Me";Owners="My Company"
From the documentation I believe I did this right(but clearly I did not). It does seem a bit confusing as to what goes in "Additional build properties" vs NuGet Arguments.
Again my goal is get the Description and Author that I set to be viewable from the NuGet Package Manager within Visual Studio.
You could create a package according to the .nuspec file.
Steps:
Generate .nuspec file for your project (command: nugget spec).
For example: (Include author and description token)
<?xml version="1.0"?>
<package >
<metadata>
<id>CommLib1</id>
<version>1.0.0.6</version>
<title>CommLib1</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
<projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
<iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>Tag1 Tag2</tags>
</metadata>
</package>
Include this file to source control
Specify Nuget Arguments (token in step 1) of Nuget Packager build step
Update1:
In general, you just need to update AssemblyInfo.cs file of your project (Author=>AssemblyCompany; Description=>AssemblyDescription; Version=>AssemblyVersion), it creates package according to this data unless it can't retrieve metadata from your assembly (I have a project has this issue).
So, steps:
Make sure nuget could retrieve necessary metadata by creating package through nuget.exe command directly in your local/build machine (nuget pack [XX].csproj)
Create a build definition (1. Visual Studio Build 2. Nuget Packager with default value 3. Nuget Publisher)
If it's building the package then there are no problems with your NuGet Packager build step. Two things need to change though.
In order to specify properties like you are doing there MUST be a tokenized *.nuspec file in the same directory as the solution file with the same name and of course the *.nuspec file needs to be checked in to VSTS/TFS.
The token name for description can't be Description.
For more details on the *.nuspec file please see the solution here:
Nuget.exe pack WARNING: Description was not specified. Using 'Description'