This article is a mirror article of machine translation, please click here to jump to the original article.

View: 20810|Reply: 0

[Source] How Jekins deploys a .NET Framework project

[Copy link]
Posted on 11/22/2018 10:29:09 AM | | | |
Note: In this article, the usage of "build", "continuous build", "compile" and "generate" is not rigorous, just know what it means.

First of all, if you want to build continuously, you need to use the command line.
But the commands of dotnet core seem to be a bit simpler than the dotnet framework project.
Because dotnetcore's build command isdotnet msbuild xxxxx.csproj/yyyyy.sln
And the build command of the dotnet framework is.../msbuild.exe xxxx.csproj/yyyyy.sln, and the most confusing thing among them (mainly people who have never fallen into a pit, just drop it) is thismsbuild.exeWhere exactly is it?msbuild.exe? After all, after installing the dotnet framework SDK or different versions of Visual Studio in Windows, there will be manymsbuild.exe, people don't understand which one to use.

Let's start with how to build a dotnet framework project in Windows, in order not to let the complexity of the project itself affect the main idea, here we think that we want to build a simple console project similar to Hello World.
In summary, the environment:
Development machine, Windows PC;
Publishing machine, Windows Server;
project, a simple dot net framework console project. (I'm using version 4.5.2 here)

on

It is best to initialize a new project on a development machine with code management such as git, so that the project can be clone on other machines with a network.
Whatever you write in the project on the development machine, as long as it can be compiled. For example, hello world.
In addition, it is recommended to add a little dependency on the nuget package to the project, and choose whatever you want, such as log4net references.
Try compiling the project on the development machine.
(After many attempts, it was confirmed that the command line should use the msbuild.exe C:\windows\Microsoft .NET\Framework\v4.xxx\msbuild.exe when compiling the project.) However, the specific project type is still based on the type, choose whether to choose Framework64 or not 64, whether it is v4.xxx or 3.x, 2.x, this meaning is very simple, if you can't understand it, it will be helpless)
If the project is under the C:\projects\test path, then the compiled command should be:

or
Of course, you may also need to bring other parameters such as /p:Configuration=Release /p:plotform="Any CPU", depending on the situation.

4. On the test machine, git clone the project and try to compile the project with the same command.
5. If you don't succeed, you must keep trying the correct msbuild.exe, path, parameters, etc., as long as there is no problem in the environment, you will definitely succeed.
6. However, here comes a very maddening question, what about nuget dependencies? Now I have no obvious problems compiling, but how do I know where to find the nuget package?
This question has stuck me for a long time.
Go to the official website of NuGet and download nuget.exe file.
After trying, this file is placed in the project (i.e. in the same directory as the SLN or CSPROJ file) and executednuget.exe restorecommand to get the required nuget package. This is the experience I got after many attempts)
Well, you can add an action to the script and execute the nuget.exe restore command every time.
It would also be a little more convenient to add nuget.exe to the environment variable (without explanation) and then execute it every time.
7. Finally, I tested and found that the project can be successfully compiled through such operations and commands on the publishing machine.
This is close to ultimate success.
In fact, for those who understand what jekins are, this is the end of the matter, and the rest can be done by themselves.

Below

1. Go to the Jekins official website, download, install, launch Jekins, register an account, no explanation. For dotnet projects, you need to install the msbuild, mstest, and mstestrunner plugins.

2. Jenkins global configuration msbuild.



3. Create a new project and configure the project



4. Build the project.

Basically, the construction is successful, and it is easy to troubleshoot even if it is not successful.

In fact, about the use of jekins, more of it is learned by oneself and tried many times to understand.

Supplement:

1. If the VS can be successfully compiled, but there is an unsupported syntax prompt in the command line.
Then it may be that the developer is compiling with more advanced syntax rules (although the project is based on the .NET framework 4.5.2), such as C# 6.0
The release machine only installed the .NET framework 4.5.2, so it does not support some of the latest syntax.
So in this case, install the latest SDK on the release machine.
As shown in the figure.
Microsoft official website SDK download:https://www.microsoft.com/net/download/visual-studio-sdks
Download the corresponding SDK.
The SDK already includes Runtime.

2. If Jekins' job needs to use the windows bat command to perform a series of operations, then using Jenkins' "Refer to the list of available environment variables" will be helpful.
Write it like "%WORKSPACE%"

3. If there is space in the path, such as C:\Program Files (x86)\Microsoft.NET, it is necessary to add double quotation marks on both sides of the variable.
As:







Previous:Jenkins briefly introduced
Next:Angular6 Material2 encapsulates the alert message prompt box
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com