Impossible to install GoogleAnalyticsTracker.Core Nuget package - nuget

I want to install the package GoogleAnalyticsTracker.Core from Nuget in my C++ project, but when I try to install, I get this error:
Could not install package 'GoogleAnalyticsTracker.Core 4.0.0'. You are trying to install this package into a project that targets 'native,Version=v0.0', 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 it cannot install it, my .NET Framework is v4.5.
This is the nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>GoogleAnalyticsTracker.Core</id>
<version>4.0.0</version>
<title>GoogleAnalyticsTracker.Core</title>
<authors>GoogleAnalyticsTracker</authors>
<owners>GoogleAnalyticsTracker</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>GoogleAnalyticsTracker - A C# library for tracking Google Analytics.</description>
<copyright>Copyright © GoogleAnalyticsTracker 2012 - 2015</copyright>
</metadata>
</package>

Related

Custom NuGet package not installing in wix project

I generate a NuGet that is is just a number of redist files that I want to use in one of my projects. If I install it in a C# or C++ projects, it works. But when I try to install it in a wixproj project and I get the following message:
Could not install package 'package-1.0.0'. You are trying to install this package into a project that targets 'Unsupported,Version=v0.0', 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 generate the package through a TeamCity task (using NuGet 5.6.0). When trying to generate the package with a NuGet CLI 5.8.1, I get the following 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 native0.0 to the nuspec*
Looked at https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128, one of the solutions was trying a dependencies group targetFramework, (I used "native0.0") with no success. My nuspec is as follows:
<?xml version="1.0"?>
<package>
<metadata>
<id>package</id>
<version>1.0.0</version>
<authors>package</authors>
<owners>owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>my package</description>
<copyright>© 2021 company, Inc</copyright>
<tags>native</tags>
</metadata>
<files>
<file src="downloads\Folder\win32.vs2017\file1.lib" target="lib\native\lib\win32.vs2017\" />
<file src="downloads\Folder\win32.vs2017\file1-debug.lib" target="lib\native\lib\win32.vs2017\" />
<file src="downloads\Folder\Include\**" target="lib\native\include\" />
<file src="build\package.props" target="build\native" />
</files>
</package>
And my props file
<Project>
<PropertyGroup>
<MyVersion>1.0.0</MyVersion>
</PropertyGroup>
</Project>
I can install other NuGet packages into wixprojects, so how I configure mine to work? Thanks.
OK I found it, the issue lies at the line
<file src="build\package.props" target="build\native" />
changing target to "build\" allows the NuGet to be loaded to any project type, included WixProj. Note that the NU5128 warning still exists though, but not an issue for me.

How to pack an x86 / x64 specific C++/CLI DLL with Nuget?

I have a C++/CLI DLL that interfaces a third party native DLL. I want to pack this as Nuget.
I followed this official MS guide, this blog post and read through this other question.
So here is what I did:
First, I created the proper nuspec file:
<?xml version="1.0"?>
<package >
<metadata>
<id>CPlusPlusNativeIFace</id>
<version>1.0.4</version>
<title>CPlusPlusNativeIFace</title>
<authors>Jens Rabe</authors>
<owners>Who owns that</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A DLL that makes a native third-party DLL available to .net</description>
<releaseNotes>foo</releaseNotes>
<copyright>errm...</copyright>
<tags>foo bar</tags>
</metadata>
<files>
<file src="..\Release\**" target="runtimes/win-x86/lib/net461" />
<file src="..\x64\Release\**" target="runtimes/win-x64/lib/net461" />
<file src="DummyAny\**" target="ref\net461" />
</files>
</package>
Then I compiled the DLL for Release x86 and Release X64. Then I created the DummyAny folder, copied the contents of the x86 one in, and used the corflags utility like in Links 2 and 3 to strip the 32 bit flag.
When I now nuget pack and nuget add, and try to reference that package in another project, I always get:
Could not install package 'CPlusPlusNativeIFace 1.0.4'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', 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 double checked that the files are right:
I have the x86 stuff in runtimes/win-x86/lib/net461
I have the x64 stuff in runtimes/win-x64/lib/net461
I have a ref/net461 folder with the manipulated dll in
But I still can't load the package.
I also tried putting the CPU specific DLLs into runtimes/win-x86/native and runtimes/win-x64/native to no avail.
What else am I missing? Does that not work for C++/CLI projects built against .net Framework?
Turned out that the official MS documentation was not usable here.
This question was/is listed as "related" here and the accepted answer there made it work for me. I used the example project on Github as a reference.
So here is how I got it to work:
Opened the project properties, went to Configuration Properties / General, selected All Configurations and All Platforms, and as Output Directory, I specified: $(ProjectDir)bin\$(Platform)\$(Configuration)\
Rebuilt the project for x86 and x64 in Release mode
Adapted the Nuspec to be like this:
<?xml version="1.0"?>
<package >
<metadata>
<id>CPlusPlusNativeIFace</id>
<version>1.0.5</version>
<title>Third Party Proxy</title>
<authors>Jens Rabe</authors>
<owners>foo</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>bar</description>
<releaseNotes>Further experimenting with nuget</releaseNotes>
<copyright>baz moo</copyright>
<tags>quux bletch</tags>
</metadata>
<files>
<file src="bin\Win32\Release\**" target="build\x86" />
<file src="bin\x64\Release\**" target="build\x64" />
<file src="bin\Win32\Release\**" target="lib\net461" />
<file src="CPlusPlusNativeIFace.props" target="build\net461" />
</files>
</package>
Added a CPlusPlusNativeIFace.props which contains the following:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Reference Include="CPlusPlusNativeIFace" Condition="'$(Platform)' == 'x86'">
<HintPath>$(MSBuildThisFileDirectory)..\x86\CPlusPlusNativeIFace.dll</HintPath>
</Reference>
<Reference Include="CPlusPlusNativeIFace" Condition="'$(Platform)' == 'x64'">
<HintPath>$(MSBuildThisFileDirectory)..\x64\CPlusPlusNativeIFace.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
Now I can do nuget pack CPlusPlusNativeIFace.nuspec and I get a Nuget package that installs correctly.

Nuget package delivers an old version of my DLL

I wrote a NuGet package that when my other projects use it they get an old version of one of my DLLs.
I include the newest version of my DLL as a reference in my NuGet project.
Project1.nuspec:
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>CommonLibrary</id>
<version>0.0.1</version>
<authors>It's Me</authors>
<owners>My Company/owners>
<description>Shared Library for Common Code and Wrapper</description>
<dependencies>
<dependency id="NLog" version="4.5.7" />
</dependencies>
</metadata>
<files>
<file src="CommonLibrary.dll" target="lib\net471" />
<file src="HelperCode.dll" target="lib\net471" />
</files>
</package>
The CommonLibrary.dll (the project) my NuGet package delivers the correct latest DLL, but that HelperCode.dll is always an older version.
in my project, I created a directory named: "binaries" and in that directory is the latest version of HelperCode.DLL. I reference that latest version in my project. So the NuGet package should deliver the latest version. I gave it a property of "Copy Local Always"
Any suggestions would be greatly appreciated.

Nuget package not adding reference on custom package

I created a nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MyPackage.dll</id>
<version>3.5</version>
<authors>Me</authors>
<owners>Me</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The description</description>
<tags>tag1</tags>
</metadata>
</package>
In a directory with the file strucutre
MyPackage
Assemblies
MyPackage.dll
MyPackage.nuspec
I created my package using nuget.exe pack myPackage.nuspec and placed it in my local sources. I can find and install it from visual studio at which point
The dll is copied into the packages directory
But the reference is not added to the project
No repositories.config is created
No packages.config is created
What am I missing?
In case someone runs into this in the future. The solution was that the 'Assemblies' directory needed to be renamed 'lib'. The documentation was wrong (been updated, now it's correct).
Big thanks to dotnetjunky over on codeplex

Nuget package cannot be installed

I set up a local nuget package repository and create a custom package.
I followed these two guides:
http://nuget.codeplex.com/wikipage?title=Hosting%20Your%20Own%20Local%20and%20Remote%20NuPack%20Feeds
http://nuget.codeplex.com/documentation?title=Creating%20a%20Package
and here is the nuspec file of my package:
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>NLog</id>
<version>1.0.0.505</version>
<authors>NLog</authors>
<description>NLog</description>
</metadata>
<files>
<file src="NLog.dll" target="lib"/>
</files>
</package>
the package was successfully created and the package shows up the package library.
But nothing happens when I click "INSTALL".
Can anyone help?
Looks like there was an issue with package building (Maybe the dll file didn't make it into lib). Try unzipping the package (rename to zip and extract) and seeing what's inside. We've updated nuget.exe and have added a -v flag to pack so that you can see the contents of your package after you build. You can install it from the ci machine http://ci.nuget.org:8080/guestAuth/repository/download/bt4/.lastSuccessful/Console/NuGet.exe).