8.4 C
New York
Monday, November 25, 2024

Upgrading a 20-year-old college challenge to .NET 6 with dotnet-upgrade-assistant



I wrote a Small digital working system for a 300-level working system class in C# for school in 2001 (?) and later moved it to VB.NET in 2002. That is all earlier than .NET Core and early variations of .NET 1.1 or 2.0 on Home windows. Yo I moved it to GitHub 5 years in the past and ported it to .NET Core 2.0 at the moment. I used to be already 15 years previous at this level, so it was cool to see this challenge working on Home windows, Linux, Docker, and a Raspberry Pi… a machine that did not exist when the challenge was initially written.

NOTE: If the timeline is complicated, I had already been working within the trade for years at this level, however I used to be nonetheless engaged on my 4-year profession at night time. It lastly took me 11 years to finish my Bachelor’s diploma in Software program Engineering.

Tonight, whereas the kids have been sleeping, I wished to see if I might execute the .NET Improve Wizard on this now 20 12 months previous app and run it in .NET 6.

Let’s begin:

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

We're focused on 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 challenge in answer: C:UsersscottTinyOSsrcTinyOSCoreTinyOSCore.csproj
(22:58:07 INF) Recommending executable TFM net6.0 as a result of the challenge builds to an executable
(22:58:07 INF) Initializing improve step Choose challenge to improve
(22:58:07 INF) Recommending executable TFM net6.0 as a result of the challenge builds to an executable
(22:58:07 INF) Recommending executable TFM net6.0 as a result of the challenge builds to an executable
(22:58:07 INF) Initializing improve step Again up challenge

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

Apparently, it’s primarily based on the primary try, with out errors.

Once I manually take a look at the .csproj, I can see some unusual model numbers, in all probability from some not-quite-ready model of .NET Core 2 that I used a few years in the past. My spidey sense is telling me that is incorrect and I suppose the replace wizard did not perceive it.

    

I additionally discover a commented reference to ILLink.Duties, which was a preview function in Mono’s Linker to scale back the ultimate dimension of purposes and crop them. A few of that performance is constructed into .NET 6 now, so I am going to use it in the course of the construct and packaging course of later. The reference is just not vital at present.

I am going to blindly replace 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 outdated dotnet which continues to be a beautiful device within the updater’s toolkit.

image

This “deprecated” device is sweet because it communicates with NuGet and confirms that newer variations of sure packages exist.

In my assessments, which have been simply batch recordsdata at this level, I used to be calling my dotnet app like this:

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

It will change to the fashionable approach with simply TinyOSCore.exe 512 scott13.txt with an exe and arguments and with out ceremony.

Publish and trim my TinyOS turns into only a 15 meg EXE. It is good contemplating that the .NET I would like is there with out the necessity for separate set up. You might flip this little artificial OS right into a microservice if you happen to wished to be completely further.

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

if I add

-p:EnableCompressionInSingleFile=true

So it is even smaller. No code modifications. I ran all my assessments, it seems good. My .NET 1.1 faculty challenge is now .NET 6.0, cross-platform, self-contained at 11 megs in a single EXE. Candy.


Sponsor: At Rocket Mortgage®, the work you do right here will likely be 100% impactful however will not take up all of your free time, supplying you with the right work-life stability. Or as we name it, stability between expertise and life! Be taught extra.




About Scott

Scott Hanselman is a former professor, former chief monetary architect, now speaker, advisor, father, diabetic, and Microsoft worker. He’s a failed comic, a scrunchie, and a guide writer.

Facebook
twitter
subscribe
About Reality Sheet

Lodging by
Hosted on an Azure App Service










Related Articles

Latest Articles