preface

Historically deployers have traditionally installed the runtime environment first and then run the release package; However, when multiple applications rely on different versions of the framework platform, if deployed on the same machine, you need to install multiple versions of the runtime on the same machine, which is always a little inconvenient, so I’ll talk about it today. Two modes of NET deployment

The body of the

There are actually two modes to choose from when distributing applications: framework-dependent mode and independent mode;

  • Framework dependent mode: the program is packaged only for itself when it is released. If the packaged program wants to run normally on other machines, the runtime of the corresponding version of the framework should be installed on the corresponding machine first, otherwise the program cannot run.
  • Standalone mode: When an application is released as a package, it is packaged with the framework it depends on. You just need to put the packaged file on the corresponding machine and run it directly, without installing the framework runtime.

Case presentation

Demonstrate the premise

Create a new MVC project, the default generated project is ok, mainly has a page, easy to demonstrate (use other forms of the same, such as API or console, etc.);

Field demonstration

Right-click the project -> click publish -> pop-up box to select the release mode, here it is recommended to choose the form of folder, after making sure, it is safer to upload to the server.

Click next to select the corresponding release folder, and the files generated by subsequent releases will go to this folder.

After specifying the path, click finish in the lower right corner to enter the following interface;

Usually, you will directly click the publish button to publish the program. In fact, by default, the program is published in framework-dependent mode. You can click show all Settings to configure, as follows:

Here’s a framework-dependent release and try it on a machine without an environment. This is to upload the release file to Linux through the Xftp tool. Before running, grant the execution permission to the startup file of the project; otherwise, the project cannot be executed as follows:

Look, it does not run, you must first install the corresponding version of the runtime.

Now switch to standalone mode to release a version, here need to pay attention to one point, when selecting standalone mode, be sure to select the target runtime, according to the running machine to select, here I want to put on Linux, so select Linux X64 (Windows, Linux, Mac can be selected from the drop-down options, Just choose the right environment for your machine).

Once the distribution package is complete, upload it to the Linux environment and run as follows:

As you can see, the standalone mode works fine.

Advantages and disadvantages of both modes
  • Framework dependent pattern

    Advantages: Small release file;

    Disadvantages: When you need to run multiple programs on the same machine, if you rely on different frameworks, you have to repeat the installation;

  • Stand-alone mode

    Advantages: Easy to deploy, different dependent programs on the same machine do not affect each other, do not need to install the corresponding version of the runtime;

    Disadvantages: Large distributed files, including library files that depend on the framework;

Here is a simple demonstration of the operation of Linux environment, other environment friends have a try; The code will not be uploaded, just a simple project demo, no changes made.

conclusion

The two modes can be deployed for their own needs. If you have many applications running on the same machine and you don’t have the isolation of containers, the standalone mode is fine. Depending on the framework, you can avoid some hassle.

Pay attention to Code Variety Circle and learn with me; I’m back