Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all 3156 articles
Browse latest View live

How to add Nuget to visual studio

$
0
0

I installed a telekit template for web chatting, it messed up my nuget package folder destination, so I lost the ability to add current/future nuget to my visual studio solutions.So I reinstalled visual studio 2019.Now am trying to add a Nuget package "Microsoft.AspNet.SignalR" to my visual studio. Any advice?


How can I install an older version of a package via NuGet?

$
0
0

I want to install an older version of a package (Newtonsoft.Json). But NuGet rolls back:

PM> Install-Package Newtonsoft.Json -Version 4.0.5Successfully installed 'Newtonsoft.Json 4.0.5'.Install failed. Rolling back...Install-Package : Already referencing a newer version of 'Newtonsoft.Json'.

How can I do it?

PackageReference version is ignored

$
0
0

In our project we're creating different NuGet packages (using suffixes) for different branches. In the .csproj file I'm trying to specify the specific version of a package that should be used.Package names can be 1.2.3, 1.2.3-rc001, or 1.2.3-pr001.

First issue:I tested using
<PackageReference Include="Package.Name" Version="[1.2.3,1.2.6)" /> where there was no 1.2.3. My understanding is it should use the next available version, but now it simply says the selected package is 1.2.3, with "Not available in this source". Updating NuGets also ignores this and simply updates to the latest release, 1.2.10. After that it overwrites the Version in .csproj, so the specified bounds are lost.

Second issue, that falls in with the first, is to specify to only use -pr* or -rc* versions. 1.2.*-pr* is not a valid option, so maybe our numbering scheme needs changing.

Could not install package '--'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5'

$
0
0

I created this package, I need it in a project but couldn't install it, this error appears:

Could not install package 'Mshwf.NiceLinq 1.0.9'. You are trying to install this package into a project that targets'.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author

I don't know why this happen, in another project (Console) I changed the framework to 4.6 and other versions and it wasn't a problem, but this only happen in this project (MVC and Web API):

this is the nuspec file:

<?xml version="1.0"?><package ><metadata><id>Mshwf.NiceLinq</id><version>1.0.9</version><title>Nice LINQ</title><authors>MShawaf</authors><owners>Mshawaf</owners><projectUrl>https://github.com/mshwf/NiceLinq</projectUrl><iconUrl>https://raw.githubusercontent.com/mshwf/NiceLinq/master/logo.png</iconUrl><requireLicenseAcceptance>false</requireLicenseAcceptance><description>See it as: WHERE ID IN (1, 2, 3, 7, 9, 22, 30, 101)</description><releaseNotes>Minor changes.</releaseNotes><copyright>Copyright 2016</copyright><tags>LINQ IEnumerable Where Contains Search Filter</tags></metadata></package>

Obtain email address from GmailService using C# client API

$
0
0

Gmail API to get profile info

Base on this link, it is possible to get the email address from the authenticated profile.Unfortunately I wasn't able to find how to get this in C# API client.

I have tried this: GmailService.Users.GetProfile("me"), but this does not contain the email address.

I hope someone know how to do this with C# API client.

Thank you.

How does the NuGet pack command generate the package version?

$
0
0

NuGet version: 4.5.1.4879

When using "project-driven" NuGet package building (i.e., passing the .csproj file to the nuget pack command), I thought I understood how NuGet will determine the version to use in the generated package. Specifically, that it will use AssemblyInformationalVersion if it exists in the AssemblyInfo, or AssemblyVersion if AssemblyInformationalVersion is not present.

That seems to work as expected in some of my assemblies (I have a simple 1:1 relationship between assemblies and packages - 1 assembly produces 1 package of the same name), but not in others.

In a problematic assembly, the AssemblyInfo includes this:

[assembly: AssemblyVersion("2.0.0.0")][assembly: AssemblyFileVersion("2.0.0.0")][assembly: AssemblyInformationalVersion("2.0.0")]

In the .csproj file I also have this, among other stuff (note the <Version> tag):

<PropertyGroup><Configuration Condition=" '$(Configuration)' == ''">Debug</Configuration><Platform Condition=" '$(Platform)' == ''">AnyCPU</Platform><ProjectGuid>{E233E8E2-EB9E-461F-80C2-63F9AFCC425D}</ProjectGuid><OutputType>Library</OutputType><AppDesignerFolder>Properties</AppDesignerFolder><RootNamespace>XYZ.Core.Messaging</RootNamespace><AssemblyName>XYZ.Core.Messaging</AssemblyName><TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion><FileAlignment>512</FileAlignment><Version>2.0.0</Version><NuGetPackageImportStamp></NuGetPackageImportStamp><TargetFrameworkProfile /></PropertyGroup>

BTW, I have no .nuspec file.

Despite those settings, when I try to build the package, using this command:

nuget pack XYZ.Core.Messaging.csproj  -OutputDirectory "c:\build\nuget-local" -Suffix "local"

It builds the package as XYZ.Core.Messaging.1.0.0-local.nupkg.

For some other packages I build with a similar command (just a different .csproj file), with the same AssemblyInfo contents, those build the package with version 2.0.0 correctly.

So where could NuGet be getting the 1.0.0 version from?

Visual Studio 2019 Project - Package - Illegal Characters in Path

$
0
0

I am seeing the following error on the "Package" tab when viewing the project properties for a Visual Studio 2019 project. Other developers are seeing the same message on their machines.

This is a .Net Standard 2.0 class library. It builds successfully and generates a valid NuGet package on build as expected. However, the property page for this tab no longer loads in the development environment.

Has anyone experienced this before?

Illegal Characters in Path

Is there a way to view which package source an installed NuGet package is from, in Visual Studio?

$
0
0

In Visual Studio's NuGet Package Manager, you can view which NuGet packages have been installed in a solution by clicking the "Installed" tab in the package manager.

However, in situations where the same package is in multiple NuGet Package Sources, it would be useful to see which package source a particular NuGet package has come from. Is there a way to see this in the NuGet Package Manager, or any where else in VS?

Edit:Copying in my comment below for clarification:

I'm creating a project using a preexisting one as a model. Both projects will need to reference the same Nuget packages, so I open up the model project in Visual Studio, open the Nuget Package Manager, and look at its installed packages. The model project has "PackageA" installed. I open the new project, open the Nuget Package Manager for it, and Browse for "PackageA". I notice that "PackageA" is available in multiple Package Sources. (These are internal to my company, not nuget,org) In my new project, I'd like to install "PackageA" from the same Package Source as the model project


Debug or Release what files should I copy to target location in nuget packaging for uwp apps?

$
0
0

I am creating a NuGet package for consumption for all my uwp apps. I have done, but I am not sure, what files(Debug or Release) should I copy to target location in NuGet packaging for uwp apps? Since, in the documentation example by Microsoft, they use only debug files. why do they copy only the debug files? why not release files? What I learned/thought from my past is, I should deliver only the release contents/components to the clients. What should I do?

  • Copy Debug files
  • Copy Release files
  • Copy Both (Debug & Release files, If so, how?)

enter image description here

I read similar questions here in StackOverflow, but I could not get answer to my scenario.

MVC bootstrap navbar not working after running NuGet updates

$
0
0

An MVC app broke after we updated all the NuGet packages. After trying everything I created a new MVC app, updated the NuGet packages and the basic navbar...

<div class="navbar navbar-inverse navbar-fixed-top"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="/">Application name</a></div><div class="navbar-collapse collapse"><ul class="nav navbar-nav"><li><a href="/">Home</a></li><li><a href="/Home/About">About</a></li><li><a href="/Home/Contact">Contact</a></li></ul><ul class="nav navbar-nav navbar-right"><li><a href="/Account/Register" id="registerLink">Register</a></li><li><a href="/Account/Login" id="loginLink">Log in</a></li></ul></div></div></div>

... looks like this ...

NavBar

...and clicking the icon...

NavBar Open

Any ideas what could be causing this?

Have tried manually adding Bootstrap.css and Bootstrap.js to _Layout.vbhtml, but no difference

Thank you

How to ignore dev dependencies in WhiteSource scan for nuget packages

$
0
0

I want to ignore my SonarAnalyzer.Csharp and Sonarlint package in the C# code WhiteSource scan. They are being captured as Policy Violation.

I checked the documentation, there is no option to ignore checking dev dependencies https://whitesource.atlassian.net/wiki/spaces/WD/pages/489160834/Unified+Agent+Configuration+File+Parameters.

Is there any option that we can provide in the WhiteSource config file to skip it. My packages.config file looks like this.

<?xml version="1.0" encoding="utf-8"?><packages><package id="SonarAnalyzer.CSharp" version="1.21.0" targetFramework="net461" /><package id="SonarLint" version="2.0.0" targetFramework="net452" developmentDependency="true" /></packages>

Print documents go to the print spool with status printing, but its not printing document using rawprint nuget packages C#

$
0
0

I am implementing print document without print dialog using rawprint nuget packages C#

When i print word document with print dialog then it adds to print queue with status "Printing" and successfullyprint the document.

When i print PDF document with "PrinterName" and FilePath using rawprint nuget packages C#, then it's add to print queue with status "Printing" But no print out from printer.

My code sample given bellow

public void printPDF(string printerName)        {            // Absolute path to your PDF to print (with filename)            string combinedPdf = new UrlHelper(System.Web.HttpContext.Current.Request.RequestContext).Content("~/temp/") +"conbined_5248422286163515789.pdf";            // The name of the PDF that will be printed (just to be shown in the print queue)            string Filepath = System.Web.HttpContext.Current.Server.MapPath(combinedPdf);            if (System.IO.File.Exists(Filepath))            {                string Filename = "conbined_5248422286163515789.pdf";                // The name of the printer that you want to use                // Note: Check step 1 from the B alternative to see how to list                // the names of all the available printers with C#                string PrinterName = printerName;                // Create an instance of the Printer                IPrinter printer = new Printer();                // Print the file                printer.PrintRawFile(PrinterName, Filepath, Filename);            }        }

Please help and suggest.

Failing to upload .snupkg file: The checksum does not match for the dll(s) and corresponding pdb(s)

$
0
0

I have a C# WPF library on NuGet. After publishing a new release (.nupkg file), I wanted to also upload the Symbols package (.snupkg file). But I get The checksum does not match for the dll(s) and corresponding pdb(s). error:

The error on NuGet

I have successfully published .snupkg file together with .nupkg file for 2 other C# .NET Framework libraries, following the exact same procedure as here. The only difference that I can think of is that this a WPF library (it has *.xaml files and it has a reference to PresentationFramework), whereas the other two aren't.


The procedure:

  1. The settings for Release configuration in the .csproj files:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU'"><DebugType>portable</DebugType><Optimize>true</Optimize><OutputPath>bin\Release\</OutputPath><DefineConstants>TRACE</DefineConstants><ErrorReport>prompt</ErrorReport><WarningLevel>4</WarningLevel><DocumentationFile>bin\Release\GM.WPF.xml</DocumentationFile><DebugSymbols>true</DebugSymbols></PropertyGroup>
  1. Rebuild (this generates .dll, .dll.config, .pdb, .xml files in bin/Release).
  2. I have a .nuspec file with the metadata for the NuGet package in the same folder as the .csproj file (I don't think it's necessary to show the .nuspec file - not relevant to this problem).
  3. Open PowerShell in this folder.
  4. Execute command nuget pack -Properties Configuration=Release -Symbols -SymbolPackageFormat snupkg (this generates .nupkg and .snupkg files).
  5. Upload .nupkg file to NuGet.
  6. Upload .snupkg file to NuGet - this is where I get the error.

Please, if you need any other information, I can provide it.

Can you target .NET Framework, .NET Standard and .NET Core in a NuGet package?

$
0
0

I'm new to creating NuGet packages and have only been playing around with them for a couple of days, as it now stands I've tested my package on .NET Frameworks 3.5 through 4.8 successfully.

By the way, this is the package: https://www.nuget.org/packages/ExcelFromList/1.0.4

My package relies on EPPlus, which is what I use as the engine. If you search for EPPlus you will see that it states that it can be installed on .NET Framework, .NET Standard, and .NET Core, I have tested this and it's correct.

So I'm not sure how to pull this off.

This is the info on my project:

  • Project is .NET 3.5
  • Using nuget.exe to create the NuGet package
  • Using .nuspec file for package creation (nuget pack <.nuspec file>)
  • Only NuGet package installed in project is EPPLus

This is my .nuspec file:

<?xml version="1.0" encoding="utf-8" ?><package><metadata><requireLicenseAcceptance>false</requireLicenseAcceptance><id>ExcelFromList</id><version>1.0.4</version><title>ExcelFromList</title><description>Straightforward and easy way to create stylized excel workbooks from lists. Add an image, title, subtitles and overal cell styles/formats. Uses the EPPlus engine.</description><releaseNotes>Succesfully tested on .NET frameworks from 3.5 through 4.8</releaseNotes><authors>Raul Marquez</authors><owners>Raul Marquez</owners><copyright>Copyright 2020 Raul Marquez</copyright><projectUrl>https://github.com/RaulMarquezInclan/ExcelFromList</projectUrl><license type="expression">GPL-3.0-only</license><tags>excel list listtoexcel</tags><dependencies><dependency id="EPPlus" version="5.1.0" /></dependencies></metadata><files><file src="bin\Debug\net35\ExcelFromList.dll" target="lib\net35" /><file src="bin\Debug\net35\ExcelFromList.xml" target="lib\net35" /></files></package>

Building the package with that configuration throws me this warning:

WARNING: NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. Consult the list of actions below: - Add a dependency group for .NETFramework3.5 to the nuspec

However, as I stated before, it still installs and runs just fine throughout the different .NET Framework versions.

When attempting to install it on .NET Standard or .NET Core it will install my dll correctly but it won't install EPPlus, which is a dependency of my package. On the .NET Standard side, I only have to manually install it and all is good, on the .NET Core side after doing the same it tells me that the executable cant run in the project.

So, where I'm confused is on how to also make them available to .NET Standard and .NET core, from searching around I've gotten hints about converting it to a .NET standard in the first place, or having three different dlls each corresponding the the different technologies and specifying them in the files section of the .nuspec file, etc.

Can anyone please point me in the right direction?

EDIT: By the way, when looking at the EPPlus package this is what we see:

EPPLus

Thanks.

Nuget Content Files in .Net core solution not getting copied when installing through Nuget

$
0
0

I'm not able to copy the content static files in my .Net core web application project that I added when creating the nuget package using nuget package explorer. Same thing get copied correctly in .Net framework project template but not in .net core template. I'm using VS 2015 update 3.Am i Missing something here? Any help would be greatly appreciated.

Below is my snapshot of content file structure.

enter image description here


Mark NuGet Package content as "Copy to Output" in consuming .NET Framework 4.8 project

$
0
0

I have a .NET Standard 2.0 project that is being packed into a NuGet package upon build. (Using the .csproj approach to generate a package on build) This project contains a file ApiClientSettings.json, which I want to copy to the output directory of the consuming project.

I have the following in my .csproj:

<ItemGroup><Content Include="ApiClientSettings.json"><CopyToOutputDirectory>Always</CopyToOutputDirectory><PackageCopyToOutput>true</PackageCopyToOutput><PackagePath>contentFiles\any\any\;content</PackagePath></Content></ItemGroup>

According to MS documentation, the PackageCopyToOutput attribute should do exactly what I want to do, but it does not seem to work when I install the package into a .NET Framework project. (Works perfectly for .NET Core project)

Am I missing anything else?

Here is my entire .csproj file:

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>netstandard2.0</TargetFramework><GeneratePackageOnBuild>true</GeneratePackageOnBuild><IsPackable>true</IsPackable><TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput><AllowedOutputExtensionsInPackageBuildOutputFolder>      $(AllowedOutputExtensionsInPackageBuildOutputFolder);.json</AllowedOutputExtensionsInPackageBuildOutputFolder><Version>1.0.40</Version><AssemblyVersion>1.0.2.0</AssemblyVersion><FileVersion>1.0.2.0</FileVersion><IncludeContentInPack>true</IncludeContentInPack></PropertyGroup><PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"><OutputPath></OutputPath></PropertyGroup><ItemGroup><Content Include="ApiClientSettings.json"><CopyToOutputDirectory>Always</CopyToOutputDirectory><PackageCopyToOutput>true</PackageCopyToOutput><PackagePath>contentFiles\any\any\;content</PackagePath></Content></ItemGroup><ItemGroup><PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" /><PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.5" /><PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.5" /><PackageReference Include="Microsoft.Extensions.Http" Version="3.1.5" /><PackageReference Include="Newtonsoft.Json" Version="12.0.3" /></ItemGroup><ItemGroup><ProjectReference Include="..\DbModelLibrary\DbModelLibrary.csproj"><ReferenceOutputAssembly>true</ReferenceOutputAssembly><IncludeAssets>DbModelLibrary.dll</IncludeAssets></ProjectReference></ItemGroup><Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage"><ItemGroup><BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" /></ItemGroup></Target></Project>

Here is my generated .nuspec file aswell:

<?xml version="1.0" encoding="utf-8"?><package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"><metadata><id>Iso17025ApiClient</id><version>1.0.40/version><requireLicenseAcceptance>false</requireLicenseAcceptance><description>Package Description</description><dependencies><group targetFramework=".NETStandard2.0"><dependency id="Microsoft.AspNet.WebApi.Client" version="5.2.7" exclude="Build,Analyzers" /><dependency id="Microsoft.Extensions.Configuration" version="3.1.5" exclude="Build,Analyzers" /><dependency id="Microsoft.Extensions.Configuration.Json" version="3.1.5" exclude="Build,Analyzers" /><dependency id="Microsoft.Extensions.Http" version="3.1.5" exclude="Build,Analyzers" /><dependency id="Newtonsoft.Json" version="12.0.3" exclude="Build,Analyzers" /></group></dependencies><contentFiles><files include="any/netstandard2.0/ApiClientSettings.json" buildAction="Content" copyToOutput="Always" /></contentFiles></metadata></package>

Cloning repo results in broken NuGet packages. Can't restore

$
0
0

Using GitKraken I cloned a repo on BitBucket. Now all the NuGet packages are broken resulting in numerous errors. I've tried to restore using the command line but it throws this error:

enter image description here

When I try to build, these are the errors that I'm getting:

enter image description here

How to fix version mismatch between web.config and packages.config?

$
0
0

I have updated some nuget packages in my solution... I have noticed that there is version mismatch between my web.config and packages.config:

This is my web.config:

enter image description here

This my packages config:

enter image description here

Note that the following 2 files have different versions:

"System.Security.Cryptography.Primitives" WebConfig="4.0.1.0" PackagesConfig="4.3.0""System.Security.Cryptography.Algorithms" WebConfig="4.3.0.0" PackagesConfigversion="4.3.1" 

Why is this happening? I have not done anything manually, I have installed everything through nuget package manager... Do I need to make any changes to either of these files?

Xamarin.Android: Package XX is not compatible with monoandroid81 (MonoAndroid,Version=v8.1)

$
0
0

I encounter a stranger behavior with a Xamarin.Android project in Visual Studio on Windows.

I've created a new Android blank project, and I try ton install the NuGet package "AForge" (a mathematics library), but I get the following error message:

Package AForge 2.2.5 is not compatible with monoandroid81 (MonoAndroid,Version=v8.1).

I've already tried to re create several projects, after having relaunched Visual Studio and the computer, but the problem is still the same.

However, if I do the same thing on Mac, through Visual Studio for Mac, I don't encounter the same problem: the package is well installed.

In add, I can see in the package.config file, that the package il well related to monodroid81:

<?xml version="1.0" encoding="utf-8"?><packages><package id="AForge" version="2.2.5" targetFramework="monoandroid81" /></packages>

Would you have any explanation about this issue?

Update: new issue

Hi @Leo Liu-MSFT, I come back to you as I encounter an new issue. The dll copy works fine locally, but I get an error on AppCenter:

CoreCompile:
/Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/4.5/csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE;XAMARIN_ANDROID_v1_0;MOBILE;ANDROID;ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4;ANDROID_5;ANDROID_6;ANDROID_7;ANDROID_8;ANDROID_9;ANDROID_10;ANDROID_11;ANDROID_12;ANDROID_13;ANDROID_14;ANDROID_15;ANDROID_16;ANDROID_17;ANDROID_18;ANDROID_19;ANDROID_20;ANDROID_21;ANDROID_22;ANDROID_23;ANDROID_24;ANDROID_25;ANDROID_26;ANDROID_27 /reference:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Java.Interop.dll /reference:/Users/vsts/.nuget/packages/microsoft.appcenter.analytics/1.7.0/lib/MonoAndroid403/Microsoft.AppCenter.Analytics.Android.Bindings.dll /reference:/Users/vsts/.nuget/packages/microsoft.appcenter.analytics/1.7.0/lib/MonoAndroid403/Microsoft.AppCenter.Analytics.dll /reference:/Users/vsts/.nuget/packages/... Services/AudioService.cs(8,7): error CS0246: The type or namespace name 'AForge' could not be found (are you missing a using directive or an assembly reference?) [/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj] Done Building Project"/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj" (PackageForAndroid target(s)) -- FAILED.

So I tried your suggestion, but I get an error when I try to save the package:

a local file header is corrupted'

Would you have another suggestion?

what's the difference between latest stable, unstable and pre-release packages

$
0
0

I'm new to nuget, sorry if my question sounds dumb:

Below is a screenshot:enter image description here

Q1- Are "latest stable 2.2.0" and "2.2.0" the same ones? It seems that they are different as I can choose one of those, what makes a package "latest stable"? it is always the latest release(2.2.0 in this case)?

Q2-I often hear people talk about publish/use an unstable package, isn't it the same idea as pre-release packages? isn't that pre-release package get its name because it is not an official relase therefore might be unstable?

Viewing all 3156 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>