将解决方案从project.json迁移到.csproj时,解决方案中的一个项目的迁移失败。
给出的错误是:
Migration failed. Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: version at NuGet.Versioning.VersionRangeBase.Satisfies(NuGetVersion version, IVersionComparer comparer)
这个错误令人费解,因为该项目包含所有已成功迁移的其他24个项目,所有项目都具有类似的project.json内容。
这是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"
}
}
}
}
这是完整的错误:
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.
project.json中有什么可以解释这个错误吗?
答案 0 :(得分:7)
原来,迁移工具不喜欢"System.Runtime": "*",
没有明确的版本号。改为"System.Runtime": "4.0.20",
工作。