Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the experience of migrating # SNMP to the .NET Core platform?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Migration #SNMP to. NET Core platform experience is what, many novices are not very clear about this, in order to help you solve this problem, the following small series will be explained in detail for everyone, there are people who need to learn in this area, I hope you can harvest.

preparation phase

First, Visual Studio 2015 is a necessary development tool. Although it already contains the original beta version of. NET Core, it is recommended to download the RC1 installation package,

http://get.asp.net

Please download ASP.NET 5 RC for that version. The following is assumed on Windows.

Execute the installer, which downloads further parts. Once the installation is complete, you can start developing. NET Core RC1 programs.

Let's upgrade to RC1 Update 1:

Open Visual Studio Command Prompt.

Execute the dnvm upgrade command.

Then execute the dnvm list command.

If everything is OK, then the output should look like this at this point,

C:\Program Files (x86)\Microsoft Visual Studio 14.0>dnvm list

Active Version Runtime Architecture Location Alias

-- --- --- ---- --- --

1.0.0-rc1-final clr x86 C:\Users\lextm\.dnx\runtimes

1.0.0-rc1-update1 clr x64 C:\Users\lextm\.dnx\runtimes

* 1.0.0-rc1-update1 clr x86 C:\Users\lextm\.dnx\runtimes default

1.0.0-rc1-update1 coreclr x64 C:\Users\lextm\.dnx\runtimes

1.0.0-rc1-update1 coreclr x86 C:\Users\lextm\.dnx\runtimes

starting the migration

Now you can open Visual Studio 2015 and create a new project of type Class Library (Package)(Visual Studio 2015 Update 1 seems to rename this project type, under study). The file suffix for this project is.xproj. The compiled result of this project will be a NuGet package.

Before we add anything new, let's examine the project.json file.

It should be noted that project.json is a completely new way to manage dependencies. It replaces both the packages.config that manages NuGet packages and the part of the original.csproj project file that manages references.

An example is the project.json file that #SNMP Library now uses,

https://github.com/lextm/sharpsnmplib/blob/netcore5/SharpSnmpLib/project.json

As we can see, there are various metadata information describing NuGet packages, as well as dependencies.

The main part is that it specifies two platform aliases, one is. NET Framework 451 (net451) and the other is. NET Platform Standard 5.4 (dotnet 5.4).

The former has a basic reference list, so it is not necessary to specify the application of the specific library, but the more special is System.Runtime.Serialization, so it is the only reference that needs to be specified.

The latter is a new alias to identify a. NET platform with a complete API manifest. Any CLR implementation that supports version 5.4 of this platform standard (not limited to. NET Framework, Mono or Xamarin) can use our compiled NuGet package. Details about platform standards can be read in the following documentation,

https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md

However, it has been updated to RC2, so the version number has been changed to calculate from 1.0.

One of the big headaches of platform-oriented standards development is that all references need to be specified manually. These references also end up in the corresponding NuGet package. So how do you find these packages and their corresponding versions?

In short, the procedure is to manually copy the code of the project to be migrated into the new project and compile it. For those types we can't find, we use a search site that Microsoft has temporarily released.

http://packagesearch.azurewebsites.net

to query the NuGet package and version that contains it. It's a bit of a time-consuming process because

Some types do not exist in RC1, and may not appear in RC2 or later versions. Therefore, it is necessary to change the flexible way.

Some types will be available in later versions, so wait.

Some types appear only in desktop versions of the. NET Framework and require conditional compilation.

As a test, I removed a lot of code during the migration of #SNMP Library. Also, since Socket type synchronization methods were removed, I had to rewrite a lot of #SNMP Library code to async/await. When Microsoft officially releases RC2, I will consider migrating some code to the past.

At this point, as long as the compilation passes, then the initial migration work is over.

written in the end

There are other things worth noting:

Visual Studio maintains a project.lock.json file corresponding to project.json. This file details dependency deployment, and understanding its structure is useful for debugging dependency problems. But don't check it into version control.

.xproj projects do not need to explicitly indicate the source files that the project contains, as does.csproj, but by default all source files under the same folder are imported. Therefore, it is possible to adjust the organization of engineering files during migration.

There is no particularly convenient unit test integration at the moment. There should be something in the back.

dotnet5.x is a temporary alias that will always change to netstandard1.x.

The above only covers the most important steps in the migration process. Some tools, such as dnvm, are not described in detail since RC2 will be replaced by dotnet tools. At this stage, it is more economical to taste it.

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report