使用PackageReference转换为VS 2017 .csproj格式

时间:2018-05-23 22:00:20

标签: vb.net visual-studio .net-core nuget csproj

我有一个遗留的解决方案,我一直在逐步升级,现在想要使用PackageReference而不是packages.config将.csproj和.vbproj文件升级到新的2017格式。

整体解决方案有大约60多个项目,因此手动迁移将非常痛苦。我一直在寻找一个实用程序来自动化该过程而没有成功。有没有人知道这样做的任何脚本?

我已尝试使用NuGet PackageReference Upgrader,但ID不起作用。我在输出窗口中出现以下错误

24/05/2018 8:37:22 AM: Update failed. Exceptions:
24/05/2018 8:37:22 AM: Message: Object reference not set to an instance of an object.
   at CloudNimble.PackageReferenceUpgrader.NuGetUpgraderPackage.<>c__DisplayClass9_1.<UpgradePackagesConfig>b__12(XElement c) in C:\projects\packagereferenceupgrader\src\CloudNimble.PackageReferenceUpgrader\NuGetUpgraderPackage.cs:line 187
   at System.Linq.Enumerable.<>c__DisplayClass6_0`1.<CombinePredicates>b__0(TSource x)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at CloudNimble.PackageReferenceUpgrader.NuGetUpgraderPackage.<>c__DisplayClass9_0.<UpgradePackagesConfig>b__1(Int32 i) in C:\projects\packagereferenceupgrader\src\CloudNimble.PackageReferenceUpgrader\NuGetUpgraderPackage.cs:line 187
   at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object )
24/05/2018 8:37:43 AM: Backup created for D:\workspace\e5tfs\dataract461\e5 Releases\Dev\e5 Foundation\e5 Legacy\Source\SharedAssemblies\Repository\packages.config.
24/05/2018 8:37:43 AM: Update failed. Exceptions:
24/05/2018 8:37:43 AM: Message: Object reference not set to an instance of an object.
   at CloudNimble.PackageReferenceUpgrader.NuGetUpgraderPackage.<>c__DisplayClass9_1.<UpgradePackagesConfig>b__12(XElement c) in C:\projects\packagereferenceupgrader\src\CloudNimble.PackageReferenceUpgrader\NuGetUpgraderPackage.cs:line 187
   at System.Linq.Enumerable.<>c__DisplayClass6_0`1.<CombinePredicates>b__0(TSource x)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at CloudNimble.PackageReferenceUpgrader.NuGetUpgraderPackage.<>c__DisplayClass9_0.<UpgradePackagesConfig>b__1(Int32 i) in C:\projects\packagereferenceupgrader\src\CloudNimble.PackageReferenceUpgrader\NuGetUpgraderPackage.cs:line 187
   at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object )

1 个答案:

答案 0 :(得分:0)

  

使用PackageReference转换为VS 2017 .csproj格式

我创建了一个带packages.config的简单示例,我可以通过NuGet PackageReference Upgrader工具将其迁移到PackageReference。根据错误日志很难找出导致错误的原因。

如果您有兴趣,可以通过Q & A与该扩展程序的所有者联系。

要完成将Packages.config迁移到PackageReference,您可以下载 Visual Studio版本15.7预览版3 ,该版本支持从packages.config管理格式迁移项目到PackageReference格式。查看Visual Studio博客:Visual Studio 2017 version 15.7 Preview 3以获取更多详细信息。