UWP Jenkins + NuGet + MSBuild teaches you to do automatic UWP Build and App store packs

Source: Internet
Author: User

Original: UWP Jenkins + NuGet + MSBuild teaches you to do automatic UWP Build and APP store packages

Background

The project needs to do the UWP auto-install package, and the previous company contacted TFS to do the auto build. The company asked Jenkins to do, don't laugh at me, before I really do not know this thing.

Will students please take a look at the point of error, not the classmate please the first self-repair, we step-by-step.

First we prepare 2 installs package, jenkins,nuget all download the newest good.

1. Install Jenkins and next step. Installed will automatically browser jump to http://localhost:8080/as

Follow the prompts to C:\Program files (x86) \jenkins\secrets\initialadminpassword file A string of GUIDs copied into, and then point continue, wait.

The first time you play the students choose the default let it install the recommended plug-in OK. Wait again ... After completion is the creation of accounts, small partners remember their account oh. I was doing the process because I forgot my account number. has also been re-installed.

If you want to reload, remember to delete C:\Program Files (x86) \jenkins this directory after uninstalling

Fill it out and start using it. Gogo

Create a new job

Select the first one and then fill in a name, click OK

To the build, create an Execute Windows Batch command

Copy the following code in

" D:\Jenkins_Test\Projects\App1\App1.sln " " C:\Users\xxxx\AppData\Roaming\NuGet\NuGet.Config " -nocache

Here, let me tell you, we have created the Jenkins_test folder in the D-disk, and the tools folder below it is the nuget.exe that we downloaded earlier.

Restore is a command for NuGet, which means that the app package you need to D:\Jenkins_Test\Projects\App1\App1.sln your project is downloaded as needed. The restoring package is the same as the one you were prompted for when you compiled the project with vs.

The-configfile behind is the designation Configflie, if not written. By default, %appdata%\nuget\nuget.config is used. We are using this file under the XXXX account you logged into Windows.

What exactly are these commands for? What other commands do you have, see nuget.exe-cli-reference. Remember to get rid of XXXX for your own account.

Next we need to create a Windows PowerShell. This requires a plugin to download PowerShell for Jenkins.

After saving, click Jenkins to return to the main page.

Click System Management, then on the right, select click Manage Plugin, search PowerShell under optional plugin item, tick click Install directly.

After the installation, we go back to the homepage, click on the newly created Test1 project again and click Configure after entering.

This time in the build, we chose Windows PowerShell.

Copy the following code in.

# Path to Msbuild tool# $msbuild="[Path to MsBuild.exe. See below for reference]"$msbuild="C:\Program Files (x86) \msbuild\14.0\bin\msbuild.exe"Set-alias MSBuild $msbuild # solution settings# $sln _name="[Path to Solution File. See below for reference]"$sln _name="D:\Jenkins_Test\Projects\App1\app1.sln"$vs _config="Release"$vs _platfom="ARM"# Call the build Methodwrite-host"Building solution ' n"-foregroundcolor greenmsbuild $sln _name/t:build/p:configuration= $vs _config/p:platform= $vs _platfom/v:q/nologo

After you've filled it out, we can save it, and after it's back, click Build Now. Such as.. Wait for the build result.

Here we will meet the first pit, I am bold to show the importance.

Build failed, we clicked on the front red ball. View the log.

' C:\windows\system32\config\systemprofile\.nuget\packages\System.ComponentModel\4.0.0\ref\netcore50\ System.ComponentModel.dll' could not being found [D:\Jenkins_Test\Projects\App1\ClassLibrary1\ Classlibrary1.csproj]

Pit 1

What you can see is that the NuGet store was successful, but in the build it ran to find the packpage under C:\windows\system32\config\systemprofile\.nuget\packages\, To view this folder locally, there is no. nuget.

and. NuGet is actually the C:\Users\xxxx under our current user

No useful information was found on the web, and when I looked at the Jenkins System Management-system information I discovered that the default home for Jenkins was under C:\windows\system32\config\systemprofile, And this is the location of the default local account when we install the system.

The first thing I want to do when I think about this place is to change home to C:\Users\xxxx.

Finally I passed this pit by modifying the Jenkins service.

Enter service to find Jenkins ' services. Click Properties-Login to see the default is the local account

Then we need to change the login account for your current system. Click this account, go to browse, search your current login account and click OK, remember to restart the service.

Once again, look at the Jenkins system Information and see that home has changed. Go Click Create Now ... Wait for build to complete.

You can see the ball turned blue and the compilation was successful.

This completes the automatic compilation. This usage scenario, I think, should be compiled automatically when the code server checks in to check if the code is correct or not.

Certainly need to write some triggers, this article did not do more research, interested students can study their own exchanges.

Below we will do the app package, that is, to test the use and upload the store package.

We create another job, like Test2.

Same as test1 to build, create an Execute Windows Batch command

Copy the following code in

D:\Jenkins_Test\Tools\nuget.exe Restore "D:\Jenkins_Test\Projects\App1\App1.sln"-configfile "C:\Users\xxxx\ Appdata\roaming\nuget\nuget.config "-nocache

Create Windows PowerShell again

# Path to Msbuild tool# $msbuild="[Path to MsBuild.exe. See below for reference]"$msbuild="C:\Program Files (x86) \msbuild\14.0\bin\msbuild.exe"Set-alias MSBuild $msbuild # solution settings# $sln _name="[Path to Solution File. See below for reference]"$sln _name="D:\Jenkins_Test\Projects\App1\App1\App1.csproj"# Call the build Methodwrite-host"Building solution ' n"-foregroundcolor greenmsbuild $sln _name/target:clean/target:rebuild/target:publish/p:configuration=release/p:appxpackagedir="D:\Jenkins_Test\AppxPackages\"/p:appxbundle=always/p:uapappxpackagebuildmode=storeupload/p:appxbundleplatforms="X86|x64|arm"

It is worth noting that:

1. Remember to use VS to the project with the store inside the necklace to get together, do not link up, you made out of the package can not upload.

Pit 2 sln_name here to note must be a startup item. csproj and not. sln

Once saved, build immediately and you'll be able to find your app package under the D:\Jenkins_Test\AppxPackages\ folder.

Pit 3

Because a package referenced in the project is not supported by any CPU, we have deleted the anycpu in the project, Note that we have deleted the SLN, and the anycpu within each sub-project.

After we've deleted it, we'll build it, without a doubt.

C:\Program Files (x86) \msbuild\14.0\bin\microsoft.common.currentversion.targets (724,5): Error:the OutputPath Property isNotSet  forProject'classlibrary1.csproj'. Please check the to make sure which you have specified a valid combination of Configuration and Platform for  ThisProject. configuration='Debug'platform='AnyCPU'. Seeing ThisMessage because you is trying to build a project without a solution file, and has specified a non-defaultConfiguration or Platform that doesn'T exist for this project. [D:\Jenkins_Test\Projects\App1\ClassLibrary1\ClassLibrary1.csproj]

Study for half a day, found that the startup item is not a problem, so the startup item and sub Project project files to compare.

Left start item, right child project

Because our child project has also been removed anycpu, but the default is to use the ANYCPU item, so this will lead us Nuget.exe restore failed.

Now that we have no anycpu in this project, we also set platform default x86.
Build again after the modifications are complete ... Perfect! Success..

Pit 4

MSbuild commnd  /target:clean; Rebuild; Publish here must write the/target:clean/target:rebuild/target:publish separately, otherwise it will not be recognized.

The folder name of the path in the command is best not to take a space, or it will be considered an illegal path.

Summarize

The above is my study of Jenkins + NuGet + MSBuild hands-on to teach you to do the automatic UWP Build and APP store package encountered in the pit, the figure is a bit more, hoping to help the needy students.

Last Updated:

2017 has recently been installed, so some paths also need to be modified.
1. Download the latest nuget.exe, go to the official website to download the latest v4.0 version, cover the previous v3.5

2.Msbuild path changed to: C:\Program Files (x86) \microsoft Visual Studio\2017\enterprise\msbuild\15.0\bin\msbuild.exe

UWP Jenkins + NuGet + MSBuild teaches you to do automatic UWP Build and App store packs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.