cloudnimble / packagereferenceupgrader Goto Github PK
View Code? Open in Web Editor NEWA VS2017 Extension that helps legacy apps migrate off of packages.config.
License: MIT License
A VS2017 Extension that helps legacy apps migrate off of packages.config.
License: MIT License
After installing, I expected to see a menu option on the right click dialog for packages.config files, I do not see that. No errors in VStudio, Tried with packagereferences as the default and without.
This page https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files
says
Important
At present, package references are supported in Visual Studio 2017 only, for .NET Core projects, .NET Standard projects, and UWP projects targeting Windows 10 Build 15063 (Creators Update).
Yet I can run it on any project type.
In a .sln file, I have a couple VB.Net projects (of type Class Library). Each references one or more NuGet packages, and under each project root is the packages.config file. The tool fails to upgrade any of the packages.config files. I've attached pasted the contents of one of the packages.config that the tool was failing on.
In the output pane, the tool logs that the current packages.config was backed up then, on the very next step, it outputs that a null reference exception occurred. Pasted below is the full output.
Output
1/18/2018 18:16:31: Backup created for C:\[redacted]\packages.config.
1/18/2018 18:16:31: Update failed. Exceptions:
1/18/2018 18:16:31: 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 )
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.KeyVault.Core" version="2.0.4" targetFramework="net47" />
<package id="Microsoft.Data.Edm" version="5.8.2" targetFramework="net47" />
<package id="Microsoft.Data.OData" version="5.8.2" targetFramework="net47" />
<package id="Microsoft.Data.Services.Client" version="5.8.2" targetFramework="net47" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net47" />
<package id="System.ComponentModel.EventBasedAsync" version="4.3.0" targetFramework="net47" />
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net47" />
<package id="System.Linq.Queryable" version="4.3.0" targetFramework="net47" />
<package id="System.Net.Requests" version="4.3.0" targetFramework="net47" />
<package id="System.Spatial" version="5.8.2" targetFramework="net47" />
<package id="WindowsAzure.Storage" version="8.0.1" targetFramework="net47" />
</packages>
Convert the items within the packages.config file to PackageReferences within the .vbproj file.
Extension is not available for Visual Studio 2019.
I wasn't able to build after upgrade because C# targets were removed by your .csproj
rewriter:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
It looks like this bit of code in NuGetUpgraderPackage.cs:
186 //RWM: Remove any Package Targets.
187 targets.Where(c => c.Attribute("Project").Value.Contains(row.Attribute("id").Value)).ToList()
188 .ForEach(c => c.Remove());
Older csproj files get 'corrupted'.
Before:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
...
After:
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
...
ToolsVersion
is not upgraded -> msbuild 14 or before can not handle <PackageReference Include="..." Version="..." />
After:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
...
However, IMHO getting into upgrading csproj to VS2017 (ToolsVersion="15.0"
) might be difficult. Even VS2017 does not handle that entirely correct for old projects (removing/adding/updating tags).
So may be only enable the upgrade for VS2015 (ToolsVersion="15.0"
) projects?
Currently the extension does not work with VS2022, when trying to install the extension the following message is shown:
Attempt to install with VS2022
Won't install
Should be able to install and use with VS2022
When running the tool packages.config deleted from disk but not from source control - TFS in my case.
Should be marked as deleted from TFS.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.