I just setup a private/local nuget gallery. I created my first package using the instructions mentioned in http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package
However I am getting the following error when i try to upload my package:
The package manifest contains an invalid Target Framework: ''
Any ideas?
[EDIT]
This is the nuspec file content within the package:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>EpsiDB</id>
<version>1.0.0.0</version>
<title>EpsiDB</title>
<authors>Microsoft</authors>
<owners>Microsoft</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>This is a test package</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2014</copyright>
<tags>Tag1 Tag2</tags>
<dependencies>
<dependency id="AntiXSS" version="4.2.1" />
<dependency id="EntityFramework" version="6.0.2" />
<dependency id="odp.net.managed" version="121.1.1" />
<dependency id="odp.net.x64" version="112.3.20" />
<dependency id="odp.net.x86" version="112.3.20" />
</dependencies>
</metadata>
This is the source code and what it is going wrong:
The problem was because of a bug in the source code. I communicated with Nuget core team and it was confirmed as a recently introduced bug which was fixed but not pushed at the time. Per grenade suggestion, I could publish my packages through Nuget.exe and I could avoid this problem altogether (because Nuget.exe wasn't built from the problematic code). However, that was not an option for me because I needed to fix the UI so other users could take advantage of the UI.
I fixed the problem myself in the Nuget source code. It was more like a serialization problem. I am sure as of now it has been fixed in the source code by the Nuget core team.
Kudos to Microsoft Nuget team for amazing support and responsiveness.
I ran into the same issue with a local NuGetGallery. I work around this by publishing from the command line (which accepts the push without an error). Eg:
NuGet.exe push <my-package>.nupkg <my-api-key> -s http://<local-nuget-server>
Related
I have a nuget package that consumed by internal teams.
This is the dependency section in the nuspec file
<dependencies>
<dependency id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="5.2.9" />
<dependency id="Newtonsoft.Json" version="12.0.2" />
<dependency id="System.Runtime.Caching" version="4.5.0" />
<dependency id="Polly" version="7.1.0" />
</dependencies>
When some teams installed my nuget package, they complained that some dlls were downgraded. For example:
and
Yes, the code does use newton. However, in my dependency section, I didn't hard code the exact version and from visual studio, it shows this and I think newton json version 13 should be bigger than 12.0.2?
Then for System.Memory, I didn't include that as a dependency, so how come its version got degraded?
There are several analyzers whose NuGet packages I almost always include in any project I make. It's annoying adding them all individually whenever I start a new project, so I have long wanted to make a NuGet package of my own that just says "include these other packages". I recently did so, and it seems to work fine. I made the following nuspec file, did a "nuget pack" and then a "nuget push" to a private package server:
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>Rwv37.Metapackage.Analyzers</id>
<version>1.0.0</version>
<authors>Robert William Vesterman</authors>
<owners>Robert William Vesterman</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A collection of frequently used analyzers.</description>
<copyright>Copyright 2019 Robert William Vesterman</copyright>
<developmentDependency>true</developmentDependency>
<dependencies>
<group targetFramework="netstandard2.0">
<dependency id="CSharpGuidelinesAnalyzer" version="3.1.0" />
<dependency id="IDisposableAnalyzers" version="2.1.2" />
<dependency id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="2.9.4" />
<dependency id="StyleCop.Analyzers" version="1.1.118" />
</group>
</dependencies>
</metadata>
</package>
I then decided to do the same thing with a bunch of test-related packages that I almost always include in all of my unit test projects:
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>Rwv37.Metapackage.UnitTesting</id>
<version>1.0.0</version>
<authors>Robert William Vesterman</authors>
<owners>Robert William Vesterman</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A collection of frequently used unit testing stuff.</description>
<copyright>Copyright 2019 Robert William Vesterman</copyright>
<developmentDependency>true</developmentDependency>
<dependencies>
<group targetFramework="netstandard2.0">
<dependency id="FluentAssertions" version="5.7.0" />
<dependency id="FluentAssertions.Analyzers" version="0.11.4" />
<dependency id="Moq" version="4.12.0" />
<dependency id="Moq.Analyzers" version="0.0.7" />
<dependency id="xunit" version="2.4.1" />
<dependency id="xunit.analyzers" version="0.10.0" />
</group>
</dependencies>
</metadata>
</package>
That did not work. When I add this metapackage to a unit testing project, I can see it (and its constituent packages) in VS 2019's Solution Explorer, but I get a bunch of errors saying things like:
The type or namespace name 'FluentAssertions' could not be found (are you missing a using directive or an assembly reference?)
I thought maybe I was misunderstanding the "developmentDependency" tag, so I removed that and bumped the version number, but this did not help.
What am I doing wrong? How do I do it correctly? Thanks.
Answering my own question:
It seems like it is due to some Visual Studio caching wackiness or something like that. As I noted in the original post, after I found that it didn't work, I removed the "developmentDependency" tag and bumped the version number, which did not help.
However, the way that I had upgraded the project to use the new version was via "Update" in VS's NuGet Package Manager. Just now, I instead tried uninstalling the old version, then installing the new version. It magically started working.
I tried each way a few more times, and it always was the same: If I "Update" version 1 to version 2, it doesn't work, but if I "Uninstall" version 1 and then "Install" version 2, it works fine. 🙄
Just for the sake of completeness, I will also mention that prior to discovering this workaround, I had tried various things like clean/rebuild, unload project/reload project, close VS/open VS, and combinations thereof (like clean/close/open/rebuild), none of which helped.
I'm trying to create a custom nuget package out of one of my projects. When I try to install it into the test project that references it, I receive this error:
Package "package" 1.0.5 is not compatible with uap10.0.15063 (UAP,Version=v10.0.15063). Package "package" 1.0.5 supports: net (.NETFramework,Version=v0.0)
This obviously isn't the case because the test project can run fine referencing the Project itself.
I'm building the nuget package based on my nuspec file:
<?xml version="1.0"?>
<package >
<metadata>
<id>Project</id>
<version>1.0.0</version>
<title>Project</title>
<authors>company</authors>
<owners>company</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>desc</description>
<copyright>cp</copyright>
<dependencies>
<group targetFramework="uap ">
<dependency id="Logging" version="1.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.NETCore" version="5.0.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.NETCore.Portable.Compatibility" version="1.0.0" exclude="Build,Analyzers" />
<dependency id="NuGet.Build" version="2.12.0" exclude="Build,Analyzers" />
<dependency id="NuGet.CommandLine" version="4.1.0" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="bin\Release\*.dll" target="lib" />
</files>
"Logging" is also a custom nuget package I created from the .csproj file of another project.
I've tried removing the tag, and also tried renaming the targetFramework="uap", none of that works.
What could be wrong and what can I try to get this working?
The target doesn't just rely on the NuSpec file, it would depend on the C# project and the dll itself. Go to:
Project> Rightclick> Properties> TargetFramework>
Set it to .Net or whatever. Also, change your output type to a console application rather than a windows application, if that is doable.
Also, you should create the nuspec file using:
Nuget spec < ProjectPath >
This gives us the advantage to just change the metadata for .csproj files, and copies that into the package metadata automatically.
I'm not a 100% sure if this will fix it, but this should be what needs to be done. Best of luck!
I have created a package for a framework which depends on numerous projects within a single solution. I want to create nuget packages for the framework and various projects within the solution.
In Framework.Framework.nuspec, I have the following dependencies declared:
<dependencies>
<group>
<dependency id="Framework.CompositionRoot" version="1.0" />
<dependency id="Framework.Services" version="1.0" />
<dependency id="Framework.Domain" version="1.0" />
</group>
</dependencies>
And in each project file has its own nuspec file, such as Framework.CompositionRoot.nuspec, which has the following dependencies:
<dependencies>
<group>
<dependency id="Super.Services" version="1.0" />
<dependency id="Super.Data" version="1.0" />
<dependency id="Super.Domain" version="1.0" />
</group>
</dependencies>
My problem is that when I install Framework.Framework in another project, it seems to install some of the dependent nuget packages but not others. In this case, it installs Framework.CompositionRoot and Framework.Services, but not Framework.Domain.
Framework.Domain has its own nuspec file in the solution and the generated Framework.Framework.nupkg file shows Framework.Domain as a dependency. I have only installed Framework.Framework in the project, not Framework.Domain, since to my understanding this should be installed when I install Framework.Framework.
When I look in the references for the solution, it has added a Framework.Domain.dll, but half of the interfaces declared in that domain are missing. (I have made sure the missing interfaces are declared as public.) However, if I copy/paste the dll into the lib folder and reference it manually, all the of the interfaces are there.
Any help would be appreciated.
This was due to nuget installing old versions by default. While Framework.Domain was not in the list of installed packages when viewing through the package manager, it was visible in packages.config, and had an old version which did not contain the interfaces. (Nuget install will install the lowest version of dependencies by default.)
In order to fix this, I uninstalled the package and re-installed it using the flag:
-DependencyVersion "HighestPatch".
I have a requirement where I need to install configuration files into the target project via NuGet. These files are meant to be edited by the end user and should therefore NEVER be updated.
I tried splitting the configuration files into their own NuGet package and using NuGet's versioning constraints to solve this, but it doesn't work. There is no way to constrain it so upgraders never get a new version AND new installers get the latest version. For example:
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- Other Stuff Omitted -->
<dependencies>
<group targetFramework="net35">
<dependency id="MyPackage.MVC4.Core" version="[$version$]" />
<dependency id="MyPackage.Web" version="[4,5)" />
</group>
<group targetFramework="net40">
<dependency id="MyPackage.MVC4.Core" version="[$version$]" />
<dependency id="MyPackage.Web" version="[4,5)" />
</group>
<group targetFramework="net45">
<dependency id="MyPackage.MVC4.Core" version="[$version$]" />
<dependency id="MyPackage.Web" version="[4,5)" />
</group>
</dependencies>
</metadata>
</package>
This keeps the upgraded version of MyProject.Web at the current version, but when installed in a new project the version of MyPackage.Web never exceeds 4.0.x even when the latest version is higher.
If I try the other end of the spectrum and use $version$, which gets replaced with the current version, then people with older versions of NuGet end up having their configuration files reset when they upgrade because they are forced to update their package.
So I would like to try a different approach. I am thinking that putting the files into a "first" directory and then copying them recursively only if they don't already exist is the target project. However, I ran into another snag - there doesn't appear to be any documentation for the $package object that is passed into the install.ps1 script.
Are there any other options of how to meet this requirement that I am unaware of?