Before we explained some of the basic knowledge about Jenkins, we can implement a more complex task with some other tools. In this article, we will introduce how to build a.Net console box with the msbuild tool and Jenkins implementation.
First, we open visual studio to create a console program, called ConsoleBuildTest, as shown below.
At this point, open windows CMD to input msbuild, if the following interface appears.
CMD can correctly locate the CMD command. If it is wrong, add the following path to the path of the environment variable:
At this time, you can input msbuild in CMD to see if you can find msbuild. If it still doesn’t work, you need to specify the location of msbuild.exe explicitly.
If the msbuild command can be a normal tool, we open Jenkins to create a freestyle project named ConsoleBuildTest.
Add Build stepSelect execute windows batch command and enter commands in the pop-up command box.
Where the quotation marks the path for the project to be built, the directory where the reader creates the project is probably not the same as mine, only to specify the SLN or csproj file for the project.
Here I do not use the msbuild command directly, but the explicit way to specify the msbuild file, because my system is loaded with mono, which always causes the msbuild to not find the location of the csc.exe file correctly, so it explicitly specifies. Of course, if a small partner is a small partnerYou don’t have vs 2017 or version that’s not the same as mine, but you can’t find msbuild.exe under the same path. If you don’t know where msbuild.exe is, recommend you to search for everything and download everything,Everything input msbuild.exe, everything will list all msbuild, where.Exe is located.
To create the completed task, we click the build now button, and if there is no error in the configuration, a build record is generated.
Click the build record into the details page, and then click console output, you will see the following icon console input.
When you open the bin/debug directory in the project directory, you will see what has been built.
Clicking on consoleTest.exe, there will be the following window
You can see that the console program is running normally and input helloworld..
If you press F5 manually or click on the visual studio, you will be wondering whether this project is generated by Jenkins or generated by visual studio. To eliminate the doubt, we change the msbuild parameter nominate.Cataloging (the default is generated in the bind\debug directory)
We clicked the configure on the left to enter the project edit mode. We changed the command content to the following
What is different from the previous one is that we have designated outdir as bin\mydebug (do not have to manually create the mydebug directory, when msbuild is generated if it does not exist automatically)
We click Save again to save the project. Then click Build Now. again.
If there is no error, there will be a successful generation record. When you open the bin directory under the project, you will see a MyDebug directory.
Notice the first pit here, though the above code is rather messy, do not use the return to branch to make it look tidy, otherwise it may be wrong when it is generated.
The default generation of the construction directory from the front is generated by default in the debug directory. If the generation mode is not specified, the debug project is generated by default, but the formal environment is to generate realease, and how to specify the realease schema,
Continue to modify the project and set the configuration as follows
If it is successful, there will be a successful record, console output as follows
When you open the bin directory in the directory, you will see more than one MyRealese folder.