I am using NuPack (https://www.nuget.org/packages/NuPack/) to create a Nuget automatically on build but when I go to upload my Nuget file, it gives me this error:
Invalid package version for a dependency with id 'Newtonsoft.Json' in package 'Float.1.0.0': ''.
What is the error telling me?
How do I fix the issue?
I am not familiar with NuPack, but usually you'd have a a nuspec and need to specify the version of your dependency:
https://learn.microsoft.com/en-us/nuget/schema/nuspec#dependencies
Look for your Newtonsoft.Json entry and provide a version following these guidelines:
https://learn.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards
Related
I've just added a nuget package for JSON validation. The docs do not specify how to "import" this package to the project and when I add using JsonSchema.Net the compiler complains The type or namespace name 'JsonSchema' could not be found. What's going on here?
Here's how I added the package.
dotnet add package JsonSchema.Net --version 2.3.0
There isn't a namespace JsonSchema.Net of version 2.3.0 from the GitHub project json-everything of this NuGet source code.
I think you might want to use Json.Schema instead of JsonSchema.Net.
There is a class JsonSchema that might help us do JSON validation.
Can someone help me understand this Visual Studio error message and suggest a fix?
I am getting the error message while scaffolding Identity.
This is the error message I get:
There was an error running the selected code generator: 'Error: An
assembly specified in the applciation dependencies manifest
(Intacct.deps.json) has already been found but with a different file
extension: package:
'Microsoft.VisualStudio.Web.CodeGeneration.Design', version: '3.1.0'
path: 'lib/net461/dotnet-aspnet-codegenerator-design.exe' previously
found assembly:
'C:\MyPath\Users\MyUser.nuget\packages\microsoft.visualstudio.web.codegeneration.design\3.1.0\lib\netcoreapp3.1\dotnet-aspnet-codegenerator-design.dll
The issue was occurred due to the NuGet manager already has a reference for Microsoft.VisualStudio.Web.CodeGeneration.Design. in the C:\Users\Lenovo\.nuget\packages\microsoft.visualstudio.web.codegeneration.design\3.1.1\ folder in C drive.
As well as the reference was also available in the Project package
Follow the below steps to resolve the error,
Goto your project and Expand Dependencies tab
Expand packages and search for Microsoft.visualstudio.web.codegeneration.design(3.1.1) package
Right-click on the package name and Remove the package.
Build the project and try.
Only reinstall package.
open Tools-> NuGet package Manager-> Package Manager Console
Update-Package -reinstall
Hello I've have a project created with linqtodb with a database in MySQL and make an upgrade so I can work with the Windows 10, the problem grow and I've been forced to remove the linq2db and all dependencies and now when I've reinstalled and try to run the connection with the database the system give me this error:
Severity Code Description Project File Line Suppression State Error Compiling transformation: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type ~\..\contentFiles\any\any\LinqToDB.Templates\LinqToDB.ttinclude 1012
UPDATE
I've made a clean of cache give me an error updating the entityframework aparently there's no way to installed because of this:
Error Could not install package 'MySql.Data 8.0.16'. 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. 0
Any help thanks in advance.
Taking into account that those templates work for everyone, I will suspect that somemething lead to corruption of templates in nuget cache from where they referenced. I would first recommend to clear nuget cache (check this link How to clear NuGet package cache using command line?) and reinstall linq2db packages. If issue still persist - it will be better if you will fill issue with environment/versions details.
I have a service that was sending bad DateTime data due to use of the JavascriptSerializer. I used Nuget to add Newtonsoft to the project, and utilized that. Here's the only place it's utilized in the code (old way, then new):
374
- var messageString = new JavaScriptSerializer().Serialize(messageDetails);
374
+ var messageString = Newtonsoft.Json.JsonConvert.SerializeObject(messageDetails);
Below is an error that occurs during the Team City build:
Consumer\MetricTrackingMQServiceConsumer.cs(374, 49): error CS0122: 'Newtonsoft.Json.JsonConvert' is inaccessible due to its protection level
Consumer\MetricTrackingMQServiceConsumer.cs(374, 61): error CS0117: 'Newtonsoft.Json.JsonConvert' does not contain a definition for 'SerializeObject'
The project compiles fine locally. Why is it failing in Team City?
As you're using NuGet to include the dependency here's the workflow I strongly suggest to avoid these type of issues.
Ensure that your reference to the Newtonsoft DLL is pointing at the NuGet packages folder.
Exclude the NuGet packages from source control.
Add a "Nuget Installer" type build step before your solution build step to restore all the NuGet packages referenced by the solution.
This has a number of advantages but most importantly given your current issue, it ensures that the version of the DLL referenced by your solution is available and in the correct location.
The following steps fixed this for me:
On your nuget installer step in your build: You may need to "Disable looking up packages from local machine cache"
Uninstall the newtonsoft reference via nuget in your project. Open the csproj file in a text editor and manually delete any remaining references to newtonsoft in there. Save the csproj file, reload your project
Reinstall newtonsoft via nuget
post your changes to your repository (git or whatever you have)
Rerun the teamcity build
I have tried setting up Ninject.Web.Mvc.FluentValidation in my ASP.NET MVC4 project
as shown below:
var ninjectValidatorFactory = new NinjectValidatorFactory(kernel);
//ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new NinjectValidatorFactory(kernel)));
FluentValidationModelValidatorProvider.Configure(x => x.ValidatorFactory = ninjectValidatorFactory);
DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
but I am getting the below errors:
Error 1 The type 'FluentValidation.ValidatorFactoryBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'FluentValidation, Version=2.0.0.0, ...
Error 2 Cannot implicitly convert type 'Ninject.Web.Mvc.FluentValidation.NinjectValidatorFactory' to 'FluentValidation.IValidatorFactory'. An explicit conversion exists (are you missing a cast?)
I can see the NuGet Package for Ninject.Web.Mvc.FluentValidation is version 3.0.0.0
and the error is telling me it is looking for version 2 of FluentValidation for its dependency.
If I install the NuGet package just for Ninject.Web.Mvc.FluentValidation then it installs the FluentValidation v2 dependency rather than version 3.4.6
but I can also see here: https://github.com/ninject/ninject.web.mvc.fluentvalidation/commit/82096d0afd15c41d01c09fd47f4247682261768e
a note about the project being updated for version 3.4.6
I am currently using NuGet to add the FluentValidation.MVC4 package to my project and then adding Ninject.Web.Mvc.FluentValidation after it (which finds it's dependency already exists and doesn't add it).
I can see that the NuGet package was last published on the 1st April 2013 but when I look at the .nuspec file in my project it shows
<dependency id="FluentValidation" version="3.2.0.0" />
Is there anything I have done wrong with this setup? or a way I can get this working through the package manager console to update the dependency version?
UPDATE: The reason for this is because Ninject.Web.Mvc.FluentValidation is using the signed version of FluentValidation which is strongly named.
David Ebbo has a good post about strong names and binding redirects here
http://blog.davidebbo.com/2011/01/nuget-versioning-part-3-unification-via.html
I still did not bother doing this to fix my problem, the NuGet package only has 1 class, the NinjectValidatorFactory, so it's worth just implementing your own.
To fix my problem for now I have put the NinjectValidatorFactoryclass into my own project. This looks to me like the current NuGet package needs to be updated further before it uses FluentValidation 3.4.6.
enter these codes in Package Manager Console :
Install-Package FluentValidation-Signed
Install-Package FluentValidation.MVC3-Signed -IgnoreDependencies
Install-Package Ninject.Web.Mvc.FluentValidation -IgnoreDependencies
-IgnoreDependencies is important .