2017-03-09 134 views
5

將解決方案從project.json遷移到.csproj時,解決方案中的一個項目的遷移失敗。鑑於vs2017遷移失敗,ArgumentNullException

錯誤是:

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會解釋這個錯誤?

回答

7

原來,遷移工具不像"System.Runtime": "*",沒有明確的版本號。更改爲"System.Runtime": "4.0.20",工作。

+0

謝謝你。遷移近模板應用需要30分鐘以上...... – Malachi

+1

不限於'System.Runtime',我用'System.Xml.Linq'和'System.Linq'解決了這個問題。研究了Nuget上的'當前'版本,並將通配符更改爲'4.3.0',允許遷移完成。 – Aaron