Thursday, December 1, 2022
HomeSoftware DevelopmentUpgrading a 20 12 months outdated College Mission to .NET 6 with...

Upgrading a 20 12 months outdated College Mission to .NET 6 with dotnet-upgrade-assistant



I wrote a Tiny Digital Working System for a 300-level OS class in C# for school again in 2001 (?) and later moved it to VB.NET in 2002. That is all pre-.NET Core, and on early .NET 1.1 or 2.0 on Home windows. I moved it to GitHub 5 years in the past and ported it to .NET Core 2.0 on the time. At this level it was 15 years outdated, so it was cool to see this venture operating on Home windows, Linux, in Docker, and on a Raspberry Pi…a machine that did not exist when the venture was initially written.

NOTE: If the timeline is complicated, I had already been working in business for years at this level however was nonetheless plugging away at my 4 12 months diploma at evening. It will definitely took 11 years to finish my BS in Software program Engineering.

This night, as the youngsters slept, I wished to see if I might run the .NET Improve Assistant on this now 20 12 months outdated app and get it operating on .NET 6.

Let’s begin:

$ upgrade-assistant improve .TinyOS.sln
-----------------------------------------------------------------------------------------------------------------
Microsoft .NET Improve Assistant v0.3.256001+3c4e05c787f588e940fe73bfa78d7eedfe0190bd

We're interested by your suggestions! Please use the next hyperlink to open a survey: https://aka.ms/DotNetUASurvey
-----------------------------------------------------------------------------------------------------------------

[22:58:01 INF] Loaded 5 extensions
[22:58:02 INF] Utilizing MSBuild from C:Program Filesdotnetsdk6.0.100
[22:58:02 INF] Utilizing Visible Studio set up from C:Program FilesMicrosoft Visible Studio2022Preview [v17]
[22:58:06 INF] Initializing improve step Choose an entrypoint
[22:58:07 INF] Setting entrypoint to solely venture in resolution: C:UsersscottTinyOSsrcTinyOSCoreTinyOSCore.csproj
[22:58:07 INF] Recommending executable TFM net6.0 as a result of the venture builds to an executable
[22:58:07 INF] Initializing improve step Choose venture to improve
[22:58:07 INF] Recommending executable TFM net6.0 as a result of the venture builds to an executable
[22:58:07 INF] Recommending executable TFM net6.0 as a result of the venture builds to an executable
[22:58:07 INF] Initializing improve step Again up venture

See how the method is interactive on the command line, with shade prompts and a sequence of dynamic multiple-choice questions?

Updating .NET project with the upgrade assistant

Apparently, it builds on the primary strive, no errors.

After I manually take a look at the .csproj I can see some bizarre model numbers, doubtless from some not-quite-baked model of .NET Core 2 I used a few years in the past. My spidey sense says that is mistaken, and I am assuming the improve assistant did not perceive it.

    <!-- <PackageReference Embody="ILLink.Duties" Model="0.1.4-preview-906439" /> -->
<PackageReference Embody="Microsoft.Extensions.Configuration" Model="2.0.0-preview2-final" />
<PackageReference Embody="Microsoft.Extensions.Configuration.Json" Model="2.0.0-preview2-final" />
<PackageReference Embody="Microsoft.Extensions.DependencyInjection" Model="2.0.0-preview2-final" />
<PackageReference Embody="Microsoft.Extensions.Choices.ConfigurationExtensions" Model="2.0.0-preview2-final" />

I additionally notice a commented-out reference to ILLink.Duties which was a preview function in Mono’s Linker to cut back the ultimate measurement of apps and tree-trim them. A few of that performance is constructed into .NET 6 now so I will use that in the course of the construct and packaging course of later. The reference isn’t wanted at present.

I am gonna blindly improve them to .NET 6 and see what occurs. I might do that by simply altering the numbers and seeing if it restores and builds, however I may also strive dotnet outdated which stays a beautiful device within the upgrader’s toolkit.

image

This “outdated” device is good because it talks to NuGet and confirms that there are newer variations of sure packages.

In my exams – which had been simply batch recordsdata at this early time – I used to be calling my dotnet app like this:

dotnet netcoreapp2.0/TinyOSCore.dll 512 scott13.txt  

It will change to the fashionable kind with simply TinyOSCore.exe 512 scott13.txt with an exe and args and no ceremony.

Publishing and trimming my TinyOS turns into only a 15 meg EXE. Good contemplating that the .NET I want is in there with no separate set up. I might flip this little artificial OS right into a microservice if I wished to be completely further.

dotnet publish -r win-x64 --self-contained -p:PublishSingleFile=true -p:SuppressTrimAnalysisWarnings=true

If I add

-p:EnableCompressionInSingleFile=true

Then it is even smaller. No code modifications. Run all my exams, appears good. My venture from college from .NET 1.1 is now .NET 6.0, cross platform, self-contained in 11 megs in a single EXE. Candy.


Sponsor: At Rocket Mortgage® the work you do round right here can be 100% impactful however received’t take all of your free time, providing you with the proper work-life steadiness. Or as we name it, tech/life steadiness! Study extra.




About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, guide, father, diabetic, and Microsoft worker. He’s a failed stand-up comedian, a cornrower, and a e-book writer.

facebook
twitter
subscribe
About   E-newsletter

Internet hosting By
Hosted in an Azure App Service










RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments