Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vs2017 Migration failed, ArgumentNullException

When migrating a solution from project.json to .csproj, migration fails for one project in the solution.

Error given is:

Migration failed. Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: version at NuGet.Versioning.VersionRangeBase.Satisfies(NuGetVersion version, IVersionComparer comparer)

This error is puzzling as the project contains 24 other projects that all migrated successfully, all with similar project.json contents.

This is the project.json

{
  "version": "1.0.0-*",

  "dependencies": {
    "EPPlus": "4.0.5",
    "Microsoft.AspNetCore.Mvc.Abstractions": "1.0.1",
    "Microsoft.AspNetCore.Mvc.Core": "1.0.1",
    "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.0.1",
    "Microsoft.Azure.DocumentDB": "1.11.1",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
    "Microsoft.Extensions.Caching.Abstractions": "1.0.0",
    "Microsoft.Extensions.Caching.Redis": "1.0.0",
    "Microsoft.Extensions.Configuration.Ini": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.7",
    "MongoDB.Driver": "2.3.0",
    "NETStandard.Library": "1.6.0",
    "RabbitMQ.Client": "4.1.1",
    "Sendgrid": "6.3.4",
    "System.Collections.Immutable": "1.3.0",
    "System.Runtime": "*",
    "WindowsAzure.ServiceBus": "3.4.4",
    "WindowsAzure.Storage": "8.0.1",
    "Unofficial.Ionic.Zip": "1.9.1.8"
  },

  "frameworks": {
    "net461": {
      "frameworkAssemblies": {
        "System.Drawing": "4.0.0.0"
      }
    }
  } 
}

This is the full error:

    ms.Lib\ms.Lib.xproj: Could not read post-migration report at 'C:\Users\alexl\AppData\Local\Temp\uf3cu05h.ayd'.

    ms.Lib\ms.Lib.xproj: Failed to migrate XProj project ms.Lib. 'dotnet migrate --skip-backup -s -x "C:\Users\alexl\git\vs2017test\eServices\ms.Lib\ms.Lib.xproj" "C:\Users\alexl\git\vs2017test\eServices\ms.Lib" -r "C:\Users\alexl\AppData\Local\Temp\uf3cu05h.ayd" --format-report-file-json' exited with error code -532462766.

    ms.Lib\ms.Lib.xproj: Migration failed. Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: version at NuGet.Versioning.VersionRangeBase.Satisfies(NuGetVersion version, IVersionComparer comparer) 

    at NuGet.Versioning.VersionRangeBase.Satisfies(NuGetVersion version) 

    at Microsoft.DotNet.ProjectJsonMigration.Rules.MigratePackageDependenciesAndToolsRule.<>c__DisplayClass11_0.<ToPackageDependencyInfo>b__2(VersionRange p) at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate) at Microsoft.DotNet.ProjectJsonMigration.Rules.MigratePackageDependenciesAndToolsRule.ToPackageDependencyInfo(ProjectLibraryDependency dependency, IDictionary`2 dependencyToVersionMap) 

    at Microsoft.DotNet.ProjectJsonMigration.Rules.MigratePackageDependenciesAndToolsRule.MigrateDependencies(Project project, MigrationRuleInputs migrationRuleInputs, NuGetFramework framework, IEnumerable`1 dependencies, SlnFile solutionFile, ProjectItemGroupElement itemGroup) 

    at Microsoft.DotNet.ProjectJsonMigration.Rules.MigratePackageDependenciesAndToolsRule.Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) 

    at Microsoft.DotNet.ProjectJsonMigration.DefaultMigrationRuleSet.Apply(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) 

    at Microsoft.DotNet.ProjectJsonMigration.ProjectMigrator.MigrateProject(MigrationSettings migrationSettings) 

    at Microsoft.DotNet.ProjectJsonMigration.ProjectMigrator.Migrate(MigrationSettings rootSettings, Boolean skipProjectReferences) at Microsoft.DotNet.Tools.Migrate.MigrateCommand.Execute() 

    at Microsoft.DotNet.Tools.Migrate.MigrateCommand.<>c__DisplayClass35_0.<Run>b__0() 

    at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) 

    at Microsoft.DotNet.Tools.Migrate.MigrateCommand.Run(String[] args) 

    at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient) 

    at Microsoft.DotNet.Cli.Program.Main(String[] args)
    ms.Lib\ms.Lib.xproj: Backing up C:\Users\alexl\git\vs2017test\eServices\ms.Lib\ms.Lib.xproj to C:\Users\alexl\git\vs2017test\eServices\Backup1\ms.Lib.xproj.
    ms.Lib\project.json: Backing up C:\Users\alexl\git\vs2017test\eServices\ms.Lib\project.json to C:\Users\alexl\git\vs2017test\eServices\Backup1\project.json.

Is there anything in the project.json that would explain this error?

like image 281
Alex Logan Avatar asked Mar 09 '17 11:03

Alex Logan


1 Answers

Turns out the migration tooling doesn't like the "System.Runtime": "*", not having an explicit version number. Changing to "System.Runtime": "4.0.20", worked.

like image 59
Alex Logan Avatar answered Nov 18 '22 15:11

Alex Logan