Why don't my nuget versions match - nuget

I get this warning building my asp.net core project on teamcity, and also appears as a warning in visual studios:
Dependency specified was Foo.Client >= 1.0.0-* but ended up with Foo.Client 1.0.25523.
I don't understand why this doesn't match. I can't seem to find any documentation on how to make these wildcard strings.
1.0.25523 is a copy a replace operation I do on my build server to reflect the build number. It's not something I'd like to directly reference, I'm just confused as to why my 1.0.0-* isn't accepting something that looks just to differ by patch version.
My package config looks something like this:
{
"version": "1.0.0-*",
"dependencies": {
"Foo.Bar.Client": "1.0.0-*",
},
"frameworks": {
"net46": {
"dependencies": {
"Foo": {
"target": "project"
}
},
"frameworkAssemblies": {
}
}
}
}
And then the substitution is made here and in the Foo.Bar.Client project.json to change "version": "1.0.0-*" to "version": "1.0.25523"

There should be a *.nuspec file for your project, which will have the information about which package version you're using. From your error message, it seems that the package version in this file is 1.0.0 whereas you'll want to change this to 1.0.25523 I think.
You can also check here for some more information.

Related

Composer is not installing the required dependencies of a forked library

There is a library on Github, named abc/xyz.
I have forked the library to update its composer.json.
The require section of its composer.json is:
{
"require": {
"xyz/abc": "^1.2",
}
}
Therequire section of the forked version is:
{
"require": {
"xyz/abc": "^2.4",
}
}
When I do composer require abc/xyz, it also downloads and installs the xyz/abc
library.
But when I use the forked version and add the following to the repositories section of my root composer.json
{
"repositories": [
{
"type": "package",
"package": {
"name": "abc/xyz",
"version": "1.2",
"dist": {
"url": "url to zip folder of the forked version",
"type": "zip"
},
"type": "library"
}
}
]
}
Now when I do composer require abc/xyz, it only downloads and installs the actual package and not the xyz/abc.
I also tried with the type: git instead of zip and changed the url to the git version but the same results.
It only downloads and installs that dependency if I use it in the root composer.json
"type": "package",
"package": {
"name": "abc/xyz",
"version": "1.2",
"dist": {
"url": "url to zip folder of the forked version",
"type": "zip"
},
"type": "library",
"require": {
"xyz/abc": "^2.4",
}
}
Is this a standard way? OR I am doing something wrong here?
When you use a repository of type package, the linked package's composer.json is not read.
The package type is meant to define the composer.json file inline, mostly for packages that do not support composer.
From the docs:
package: If you depend on a project that does not have any support for Composer whatsoever you can define the package inline using a package repository. You basically inline the composer.json object.
(emphasis mine)
If your package does support composer (e.g. includes a composer.json file that defines dependencies, autoloader, etc.), use type vcs.
To use a forked version, you simply add a repository that includes the forked version. Typically, for forks I simply depend on dev-master/dev-main, because the fork is not really published and only includes some hot-fixes that do not exist in the "main" package. Or dev-whatever-branch-your-fixes-exist.
Assuming your fork of xyz/abc is hosted on https://github.com/ahmad/abc, your root composer.json should be something like:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ahmad/abc"
}
],
"require": {
"xyz/abc": "dev-master"
}
}
(Just added the relevant parts, obviously this doesn't mean you have to delete the rest of your root composer.json file, just change the appropriate bits)

Application dependency not found while release by the build agent

My .NETStandard library works fine locally on Visual Studio. But, when I release the WebApi containing my .NETStandard library the release proces failed on the EF Core Migrations step.
I use the Deploy Entity Framework Core Migrations release task by #bendayconsulting. The error message I receive is n assembly specified in the application dependencies manifest (MySecondMobileApp.ServerData.deps.json) was not found:
package: 'Google.Protobuf', version: '3.5.1'
path: 'lib/netstandard1.0/Google.Protobuf.dll
When I look at the packages folder at my solution there is no Google.Protobuf assembly. The assembly is stored at my global NuGet folder and is part of the MySql.EntityFrameWorkCore NuGet package. The MySql.EntityFramworkCore package is also installed at my user's global NuGet folder. How can I get these packages in the solution's folder? I think that is the answer of my problem.
My deps file looks like this:
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": "19d3dd659b5fa2adabeefcff78ce8381da3d4fe9"
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"ClassLibrary1/1.0.0": {
"dependencies": {
"Google.Protobuf": "3.6.1",
"NETStandard.Library": "2.0.3"
},
"runtime": {
"ClassLibrary1.dll": {}
}
},
"Google.Protobuf/3.6.1": {
"dependencies": {
"NETStandard.Library": "2.0.3"
},
"runtime": {
"lib/netstandard1.0/Google.Protobuf.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
}
}
},
"Microsoft.NETCore.Platforms/1.1.0": {},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
}
}
},
"libraries": {
"ClassLibrary1/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Google.Protobuf/3.6.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-D/h9IZl76jjfM5VlPzG235Zdys9RKXNLYbRGm2fa6Y2UshTqAvYBPIydNOvNTEa24DER/m/zvelHlLO9n1GtNQ==",
"path": "google.protobuf/3.6.1",
"hashPath": "google.protobuf.3.6.1.nupkg.sha512"
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
}
}
}
Configure a package management feed (Azure Artifacts) and push your internal packages to it, then use a NuGet restore task in your build prior to building to restore the packages from your internal feed.
Finally, I resolved this problem. First, I will apologize from my incomplete question. I had to told stackoverflow my whole problem. My base problem is that I couldn't release my WebAPI containing EntityFrameworkCore for MySql on a Hosted2017 build agent in Azure Devops. The Build Agent also excutes the database migrations.
After some thoughts I relealized that a MySqlConnection not is supported by .NET by default -> you have to install additional client software on the build agent. Unfortunately the Microsoft build agents don't have the capability to establish a MySQLConnection between the build agent and the MySQL database server.
What completely vage is for me at this moment is the fact that the API WebServer on AWS supports this databaseconnection by default. My WebAPI is working perfect on the webserver.
The solution for me to make the build agent work with MySQL was to install an on premise build agent and install MySQL Workbench to install the MYSQL software.
Now the build agent is working fine. The migrations are successfully executed.

Visual Studio Code: Missing X509Certificate2UI

I get the following error when trying to use an X509Certificate2UI in VS Code:
The type or namespace name 'X509Certificate2UI' does not exist in the namespace 'System.Security.Cryptography.X509Certificates' (are you missing an assembly reference?) [netcoreapp1.1]
I've found a few sites that indicate the solution is to add the system.security.dll assembly, but these responses don't seem to be catered toward VS Code. I've already added the X509Certificates dependency to the project.json file, which doesn't seem to do me much good:
},
"dependencies": {},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
},
"System.Security.Cryptography.X509Certificates": "4.3.0" //"4.3.0-*"
},
"imports": "dnxcore50"
}
Any help would be greatly appreciated :)
-Nate
X509Certificate2UI is not part of .NET Core. It's a Windows-only class, and a UI class at that, and it was not carried over.
You will have to move to a UI-free solution, or cross-compile to target .NET Framework.

Composer package not found in any version

I am trying to create a custom vendor package but have not yet put the package on packagist. According to the docs, the package can be loaded from git (vcs) instead of packagist: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository
The yii2 project (although don't think framework matters) I have created package inside vendor folder:
foundationize/yii2-foundation
(folder structure is as above, I have quadruple-checked).
My root public_html/composer.json has following entries:
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": ">=2.0.5",
"yiisoft/yii2-swiftmailer": "*",
"foundationize/yii2-foundation": "dev-master"
},
My package composer file, vendor/foundationize/yii2-foundation/composer.json looks like:
{
"name": "foundationize/yii2-foundation",
"description": "The Foundation extension for the Yii2 framework",
"keywords": ["yii2", "foundation"],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/foundationize/yii2-foundation/issues",
"wiki": "https://github.com/foundationize/yii2-foundation/wiki",
"source": "https://github.com/foundationize/yii2-foundation.git"
},
"authors": [
{
"name": "gvanto",
"email": "gvanto#hotmail.com",
"homepage": "http://foundationize.com"
}
],
"require": {
"yiisoft/yii2": "*"
},
"autoload": {
"psr-4": {
"foundationize\\foundation\\": ""
}
},
"repositories": [
{
"packagist": false,
"type": "vcs",
"url": "https://github.com/foundationize/yii2-foundation.git"
}
]
}
When I run composer install (or update), I keep getting error below:
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- The requested package foundationize/yii2-foundation could not be found in any version, there may be a typo in the package name.
Potential causes:
A typo in the package name
The package is not available in a stable-enough version according to your minimum-stability setting see
https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion
for more details.
Read https://getcomposer.org/doc/articles/troubleshooting.md for
further common problems.
I have googled it high and low, read the docs can't seem to get it to work (always the same error, which I actually think would be more useful if it said either the package was not found OR the incorrect package version was found).
You have to add the repositories entry to your root composer.json file. Otherwise, Composer does not know where to search for your package.
Had a similar problem to this and it was because I was running composer in the /web directory in the new Drupal structure. When I ran it in the root all was fine. Annoyingly, you need to run Drush in /web
Since Laravel version 5.5 there is a Package Auto-Discovery feature, so there is no need to add service provider. All you need to register package like this:
composer require barryvdh/laravel-debugbar:dev-master
You can find more info in these articles:
https://medium.com/#taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518
https://divinglaravel.com/laravels-package-auto-discovery

Building Google Analytics package in ASP.NET Core 5.0

I am trying to include Google Analytics API package in my MVC 6 application. I've tried to include all the dependencies or to let it install trough NuGet Package Manager. In either case, when i build the solution, I get an error: Error CS0246 The type or namespace name 'Google' could not be found (are you missing a using directive or an assembly reference?) ProjectName.ASP.NET Core 5.0
Any idea what dependencies I need to include for it to build in ASP.Net Core 5.0?
Here is what i have in my project.json file:
"dependencies": {
...
"Microsoft.Net.Http": "2.2.28.0",
"Microsoft.Bcl": "1.1.9.0",
"Microsoft.Bcl.Build": "1.0.21.0",
"Microsoft.Bcl.Async": "1.0.168.0",
"Google.Apis.Analytics.v3": "1.9.0.1100"
},
...
"frameworks": {
"aspnet50": {
"dependencies": {
}
},
"aspnetcore50": {
"dependencies": {
"Newtonsoft.Json": "6.0.8.0"
}
}
},
Similar issue to the one described here: Problems with RavenDB.Client reference in asp.net 5.0 project.json
Adapting my answer from there:
The problem is that you referencing Google.Apis.Analytics.v3 in the top level dependencies node in project.json. That means that those dependencies are applicable to both Desktop CLR (aspnet50) and CoreCLR (aspnetcore50).
When you build an ASPNET 5 project, all configurations are built, not just the "active" one. Mostly sure Google.Apis.Analytics.v3 works only with the Desktop CLR so move it under a dependencies node under that configuration.
"dependencies": {
....
},
"frameworks": {
"aspnet50": {
"dependencies" : {
"Google.Apis.Analytics.v3": "1.9.0.1100"
}
},
"aspnetcore50": {}
}
Then you might have to either use some conditional blocks in your code (#if ASPNET50) or remove CoreCLR all together.
Then you might have to either use some conditional blocks in your code (#if ASPNET50) or remove CoreCLR all together.