React Native for Windows and native modules: how to add CI/CD to your project

Published 01-02-2020 01:25 AM 3,280 Views
Microsoft

In the previous post we have learned how to create a CI/CD pipeline on Azure DevOps to automatically build and deploy a Windows application built with React Native. Everything worked fine but, in that scenario, I used as a sample the basic React Native template, which doesn't leverage any native module. Especially when you're building a real application, however, it's a very uncommon scenario. At some point, you will have to interact with any of the native features offered by the platform, even if it's a simple one like the file system. For this reason, in another blog post I wrote, we have learned how we can build native modules for Windows, so that your React Native application can access to native Windows features using JavaScript.

 

However, as soon as you try to setup a CI/CD pipeline following the guidance of the previous post for your React Native project which uses native modules for Windows, you hit a blocker. The Visual Studio build task will fail with a series of errors like the following ones:

 

[error]node_modules\react-native-windows\Microsoft.ReactNative.SharedManaged\AttributedViewManager.cs(447,21): Error CS8107: Feature 'default literal' is not available in C# 7.0. Please use language version 7.1 or greater.

[error]node_modules\react-native-windows\Microsoft.ReactNative.SharedManaged\JSValue.cs(105,36): Error CS8107: Feature 'readonly references' is not available in C# 7.0. Please use language version 7.2 or greater.

The reason is that, when you build a native module in C#, you reference a project included in the React Native for Windows implementation called Microsoft.ReactNative.SharedManaged, which provides various attributes to expose C# classes and methods to JavaScript. This project leverages many features of the C# language that has been added after the 7.0 release, which aren't supported by Visual Studio 2017, that is the version installed on our hosted agent. We need to switch to Visual Studio 2019 but we can't just do that: the React Native for Windows implementation leverages many C++ projects which target the v141 C++ platform toolset, which is installed by default in Visual Studio 2017 but not in Visual Studio 2019.

 

Shall we give up in our plan of using Azure DevOps to build a CI/CD pipeline for this scenario? Absolutely not! Self-hosted agents to the rescue =)

 

Setting up the self-hosted agent

For scenarios like this, where the available hosted agents don't meet our requirements, Azure DevOps supports the concept of self-hosted agents. A self-hosted agent is nothing more than a regular machine, where you deploy an agent which is able to receive tasks from Azure DevOps and execute them. The agent is an application that can run in interactive mode or simply be installed as a service, so that it can performs all the operations in background. The advantage of a self-hosted agent is its flexibility: being a regular machine, you can install everything you need to satisfy your requirements: development tools, SDKs, frameworks, etc. This helps also to reduce the execution times of a pipeline. Sometimes, some of our requirements can be satisfied also on hosted agents with installation tasks: for example, in the previous post we have learned how to use Chocolatey to install the Windows 10 1903 SDK, which is missing on the vs2017-win2016 agent. However, all these tasks must be added on top of the compilation time, making the whole execution longer.

 

The downside of a self-hosted agent is that you need to maintain it. You need to keep it up & running, you need to patch it, you need to pay for it, etc. Hosted agents, instead, are maintained directly by Microsoft. The difference between a hosted agent and a self-hosted agent is not very different between choosing a IaaS (Infrastructure as a Service) or PaaS (Platform as a Service) approach for running an application in the cloud.

 

Setting up a self-hosted agent is a quite straightforward operation. First, you need to have a machine that you want to use as an agent. It can be any kind of machine: physical, virtual, in the cloud. As long as it's connected to Internet, you're good to go. Of course, the best approach is to use a dedicated virtual machine, where you're going to install only the tools you need to perform the compilation. In my case, I opted for creating a dedicated VM on Azure. If you have a Visual Studio subscription linked to your Azure account, you can choose one of the available Windows 10 Pro images (in my case, I chose the most recent version, Windows 10 1909). Otherwise, you can choose a Windows Server 2019 image as well.

 

Windows101909.png

As size, keep in mind that disk speed is very important. React Native for Windows is built on top of C++ and, as such, the compilation times are quite long. If you choose a cheap storage (like a regular HDD instead of SSD), the compilation time will be very long. My suggestion is to go, at least, with a DS2_V2, which is the same size leveraged by the Microsoft hosted agents.

 

VMsize.png

 

Once your VM is up & running, regardless if you have created it locally or in the cloud, you will need to setup the agent.

 

Configuring the agent

I won't go into all the details on how to setup a self-hosted agent, since my colleague Freist has explained it in a great way in the following blog post. Also the official documentation does a great job in explaining all the required steps.

 

The process is really easy. You just need to download a package from the Azure DevOps website, copy it over on your machine and run a script to configure it. The script will ask you a few questions, like the security token to connect your Azure DevOps instance, the work folder, if you want to install the agent as a Windows Service, etc. Once the operation is complete, you're all set. The agent will take care of communicating with Azure DevOps via HTTPS, to exchange information: it will receive the tasks to perform and it will send back the produced artifacts.

 

Once the agent is up & running, you can start installing all the tools you need to compile our React Native for Windows project. Let's see them.

 

Visual Studio 2019

Any version, including the Community one, will be fine. Just make sure to install the workloads and components required by React Native, which are described in the official documentation:

  • Workloads
    • Universal Windows Platform development
      • Enable the optional C++ (v141) Universal Windows Platform tools
    • Desktop development with C++
  • Individual Components
    • Compilers, build tools and runtimes
      • VC v141 - VS 2017 C++ x64/x86 build tools (v14.16)
      • MSVC v141 - VS 2017 C++ ARM build tools (v14.16)

 

Chocolatey

We have already talked about Chocolatey in the previous post. It's a popular package manager for Windows and it's the easiest way to install software on a machine (especially a build agent), since everything can be done via command-line, without requiring any user interaction. To install it, you just need to open an administrative PowerShell prompt on the VM (the easiest way is to right click on the Start button and choose Windows PowerShell (Admin)) and launch the following command:

 

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Once the tool is installed, you'll be able to install applications just by launching choco install followed by the unique identifier of the package. You can explore all the available packages on the official website.

 

Node.js

You will need Node.js installed on the machine, since it's leveraged by React Native to handle all the modules. Now that we have Chocolatey on the machine, installing Node.js is really easy. Open a PowerShell prompt with administrative rights and run the following command:

 

choco install nodejs.install --version=12.9.1

Make sure to specify the --version property, since 12.9.1 is the Node.js version which works best with React Native at the time of writing. Different versions can lead to errors during the bundle generation.

 

Yarn

When you commit your React Native project to your repository, by default the node_modules folder is ignored. These are libraries and tools which haven't been developed by us, so it wouldn't make sense to waste space on our repository for stuff that can be easily downloaded. As such, you will have to restore all the dependencies before running the compilation. The best way to do is to leverage Yarn, a popular package manager for Node. Also Yarn is available on Chocolatey, so you can just run the following command from a PowerShell prompt with administrative rights:

 

choco install yarn

 

React Native CLI

During the compilation of the package, at some point Visual Studio will launch the react-native bundle command, which bundles all the JavaScript files together so that you don't need the Metro packager up & running to launch the application. In order to achieve this task, you will need to install first the react-native-cli package globally. However, there's a catch, which we have learned about also in the previous post. The React Native CLI must be available to the user which runs the build agent service, otherwise Visual Studio won't be able to find it. In case of a hosted agent, we learned that the user that runs this service is called VssAdministrator. What about self-hosted agents? If you have installed the agent as a service using the default options, the service will be running using the Network Service user or the Local System account, which are special users that doesn't have a dedicated account. As such, you have two options:

  1. You can create on the machine a dedicated user with administrator rights, which will be dedicated to the agent service.
  2. You can use your current default user to run the agent service.

Regardless of your choice, to change this behavior open the Start menu and type:

 

services.msc

You will open a window that will list all the services installed in the system. Look for the agent service, which will be called Azure Pipelines Agent, followed by the a string composed by:

  • The name of your Azure DevOps account
  • The name of the pool the agent belongs to
  • The name of the machine

For example, in my case it's called Azure Pipelines Agent (mpagani-ms.Default.VSPreviewBuild).

 

AgentName.png

 

Now double click on it to open its properties and move to the Log on section. Select the This account option and, with the Browse button, search for the user on the machine you have decide to use to run the service. In my case, I chose to leverage my current user, which is called qmatteoq and he has administrator rights. You will need to provide also the password of the account.

 

ServiceUser.png

 

Once you have setup the user who runs the agent, you're ready to install the React Native CLI. Open an administrative prompt and run first the following command:

 

npm config set prefix C:\Users\qmatteoq\AppData\Roaming\npm

Make sure to replace qmatteoq with the name of the user you have chosen to run the service. This command will set the default folder which will be used as cache for NPM packages. Now you can install the CLI with the following command:

 

npm install -g react-native-cli

That's it. This was the last requirement to install on the machine. Now we can go back to the Azure DevOps portal and create our pipeline.

 

Setup the CI/CD pipeline

The process of creating a CI/CD pipeline isn't very different from the one we did in the previous post. In your Azure DevOps project move to the Pipelines section, create a new pipeline, choose where your source code is hosted and, in the end, choose Universal Windows Platform as last template. We will need, also in this case, to make a few tweaks, but we will have to perform fewer steps. In the previous post, in fact, we were leveraging a hosted agent, so we needed to install every time the missing dependencies, like the Windows 10 1903 SDK or the React Native CLI. In our scenario, instead, we have already installed all the dependencies on the machine, so we don't need to install them every time we perform a new build.

Here is how your YAML file should look like:

 

# Universal Windows Platform
# Build a Universal Windows Platform project using Visual Studio.
# Add steps that test and distribute an app, save build artifacts, and more:
# https://aka.ms/yaml

trigger:
- master 

pool: Default

variables:
  solution: 'windows/*.sln'
  buildPlatform: 'x64'
  buildConfiguration: 'Release'
  appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'

name: $(date:yyyy).$(Month)$(rev:.r).0

steps:

- task: VersionAPPX@2
  displayName: 'Version MSIX'
  inputs:
    Path: '$(Build.SourcesDirectory)'
    VersionNumber: '$(Build.BuildNumber)'
    InjectVersion: true

- script: yarn install

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: 'windows/*.sln'
    feedsToUse: 'select'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:AppxBundlePlatforms="$(buildPlatform)" /p:AppxPackageDir="$(appxPackageDir)" /p:AppxBundle=Never /p:UapAppxPackageBuildMode=SideloadOnly /p:AppxPackageSigningEnabled=false'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(appxPackageDir)'
    ArtifactName: 'drop'

Let's see which are the major differences compared to the one we have created in the previous post:

  • We have set the pool property to Default. If you have setup the agent on the machine using the default settings, it will belong to the Default pool. With this setting we're telling to Azure DevOps that we don't want to use a hosted agent, but our custom one.
  • We don't need anymore to install Yarn, the Windows 1903 SDK and the React Native CLI at every build. We have already installed them when we have configured the machine.

The rest of the steps are the same:

  1. We change the build number, so that it's compliant with the rules required by a MSIX manifest to define a version number (x.y.z.0). Then, using the VersionAPPX task, we inject it in the manifest of your application.
  2. We restore all the Node dependencies with the yarn install command.
  3. We restore the NuGet packages required by React Native for Windows.
  4. We build the project using Visual Studio.
  5. We publish the build artifacts on Azure DevOps, so that other pipelines (like a release pipeline) can pick it to perform additional tasks, like performing a deployment.

 

That's all folks!

That's it! Now we have a CI pipeline that can automatically build a new MSIX package every time we commit some code to the repository of our React Native project which uses one or more native modules for Windows. Now we can build a release pipeline, which will take care of deploying the MSIX package we have just created to our users: we can upload it on the Microsoft Store, we can upload it on a website or cloud storage to make it available through sideloading, etc. You can learn more about this in the last chapter of my latest e-book titled MSIX Succinctly, which has been published and released for free by Syncfusion, or in Exercise 6 of the Windows application modernization workshop built by my team.

 

Happy coding!

%3CLINGO-SUB%20id%3D%22lingo-sub-1085473%22%20slang%3D%22en-US%22%3EReact%20Native%20for%20Windows%20and%20native%20modules%3A%20how%20to%20add%20CI%2FCD%20to%20your%20project%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1085473%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fwindows-dev-appconsult%2Fcreate-a-ci-cd-pipeline-for-a-react-native-for-windows%2Fba-p%2F1083253%22%20target%3D%22_blank%22%3EIn%20the%20previous%20post%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewe%20have%20learned%20how%20to%20create%20a%20CI%2FCD%20pipeline%20on%20Azure%20DevOps%20to%20automatically%20build%20and%20deploy%20a%20Windows%20application%20built%20with%20React%20Native.%20Everything%20worked%20fine%20but%2C%20in%20that%20scenario%2C%20I%20used%20as%20a%20sample%20the%20basic%20React%20Native%20template%2C%20which%20doesn't%20leverage%20any%20native%20module.%20Especially%20when%20you're%20building%20a%20real%20application%2C%20however%2C%20it's%20a%20very%20uncommon%20scenario.%20At%20some%20point%2C%20you%20will%20have%20to%20interact%20with%20any%20of%20the%20native%20features%20offered%20by%20the%20platform%2C%20even%20if%20it's%20a%20simple%20one%20like%20the%20file%20system.%20For%20this%20reason%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-Dev-AppConsult%2FBuilding-a-React-Native-module-for-Windows%2Fba-p%2F1067893%22%20target%3D%22_blank%22%3Ein%20another%20blog%20post%20I%20wrote%3C%2FA%3E%2C%20we%20have%20learned%20how%20we%20can%20build%20native%20modules%20for%20Windows%2C%20so%20that%20your%20React%20Native%20application%20can%20access%20to%20native%20Windows%20features%20using%20JavaScript.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20as%20soon%20as%20you%20try%20to%20setup%20a%20CI%2FCD%20pipeline%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fwindows-dev-appconsult%2Fcreate-a-ci-cd-pipeline-for-a-react-native-for-windows%2Fba-p%2F1083253%22%20target%3D%22_blank%22%3Efollowing%20the%20guidance%20of%20the%20previous%20post%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efor%20your%20React%20Native%20project%20which%20uses%20native%20modules%20for%20Windows%2C%20you%20hit%20a%20blocker.%20The%20Visual%20Studio%20build%20task%20will%20fail%20with%20a%20series%20of%20errors%20like%20the%20following%20ones%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22language-plaintext%20hljs%22%3E%5Berror%5Dnode_modules%5Creact-native-windows%5CMicrosoft.ReactNative.SharedManaged%5CAttributedViewManager.cs(447%2C21)%3A%20Error%20CS8107%3A%20Feature%20'default%20literal'%20is%20not%20available%20in%20C%23%207.0.%20Please%20use%20language%20version%207.1%20or%20greater.%0A%0A%5Berror%5Dnode_modules%5Creact-native-windows%5CMicrosoft.ReactNative.SharedManaged%5CJSValue.cs(105%2C36)%3A%20Error%20CS8107%3A%20Feature%20'readonly%20references'%20is%20not%20available%20in%20C%23%207.0.%20Please%20use%20language%20version%207.2%20or%20greater.%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThe%20reason%20is%20that%2C%20when%20you%20build%20a%20native%20module%20in%20C%23%2C%20you%20reference%20a%20project%20included%20in%20the%20React%20Native%20for%20Windows%20implementation%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMicrosoft.ReactNative.SharedManaged%3C%2FSTRONG%3E%2C%20which%20provides%20various%20attributes%20to%20expose%20C%23%20classes%20and%20methods%20to%20JavaScript.%20This%20project%20leverages%20many%20features%20of%20the%20C%23%20language%20that%20has%20been%20added%20after%20the%207.0%20release%2C%20which%20aren't%20supported%20by%20Visual%20Studio%202017%2C%20that%20is%20the%20version%20installed%20on%20our%20hosted%20agent.%20We%20need%20to%20switch%20to%20Visual%20Studio%202019%20but%20we%20can't%20just%20do%20that%3A%20the%20React%20Native%20for%20Windows%20implementation%20leverages%20many%20C%2B%2B%20projects%20which%20target%20the%20v141%20C%2B%2B%20platform%20toolset%2C%20which%20is%20installed%20by%20default%20in%20Visual%20Studio%202017%20but%20not%20in%20Visual%20Studio%202019.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EShall%20we%20give%20up%20in%20our%20plan%20of%20using%20Azure%20DevOps%20to%20build%20a%20CI%2FCD%20pipeline%20for%20this%20scenario%3F%20Absolutely%20not!%20Self-hosted%20agents%20to%20the%20rescue%20%3D)%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22setting-up-the-self-hosted-agent%22%20id%3D%22toc-hId-1060461589%22%20id%3D%22toc-hId-1060461589%22%3ESetting%20up%20the%20self-hosted%20agent%3C%2FH3%3E%0A%3CP%3EFor%20scenarios%20like%20this%2C%20where%20the%20available%20hosted%20agents%20don't%20meet%20our%20requirements%2C%20Azure%20DevOps%20supports%20the%20concept%20of%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fagents%2Fagents%3Fview%3Dazure-devops%26amp%3Btabs%3Dbrowser%23install%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eself-hosted%20agents%3C%2FA%3E.%20A%20self-hosted%20agent%20is%20nothing%20more%20than%20a%20regular%20machine%2C%20where%20you%20deploy%20an%20agent%20which%20is%20able%20to%20receive%20tasks%20from%20Azure%20DevOps%20and%20execute%20them.%20The%20agent%20is%20an%20application%20that%20can%20run%20in%20interactive%20mode%20or%20simply%20be%20installed%20as%20a%20service%2C%20so%20that%20it%20can%20performs%20all%20the%20operations%20in%20background.%20The%20advantage%20of%20a%20self-hosted%20agent%20is%20its%20flexibility%3A%20being%20a%20regular%20machine%2C%20you%20can%20install%20everything%20you%20need%20to%20satisfy%20your%20requirements%3A%20development%20tools%2C%20SDKs%2C%20frameworks%2C%20etc.%20This%20helps%20also%20to%20reduce%20the%20execution%20times%20of%20a%20pipeline.%20Sometimes%2C%20some%20of%20our%20requirements%20can%20be%20satisfied%20also%20on%20hosted%20agents%20with%20installation%20tasks%3A%20for%20example%2C%20in%20the%20previous%20post%20we%20have%20learned%20how%20to%20use%20Chocolatey%20to%20install%20the%20Windows%2010%201903%20SDK%2C%20which%20is%20missing%20on%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Evs2017-win2016%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eagent.%20However%2C%20all%20these%20tasks%20must%20be%20added%20on%20top%20of%20the%20compilation%20time%2C%20making%20the%20whole%20execution%20longer.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20downside%20of%20a%20self-hosted%20agent%20is%20that%20you%20need%20to%20maintain%20it.%20You%20need%20to%20keep%20it%20up%20%26amp%3B%20running%2C%20you%20need%20to%20patch%20it%2C%20you%20need%20to%20pay%20for%20it%2C%20etc.%20Hosted%20agents%2C%20instead%2C%20are%20maintained%20directly%20by%20Microsoft.%20The%20difference%20between%20a%20hosted%20agent%20and%20a%20self-hosted%20agent%20is%20not%20very%20different%20between%20choosing%20a%20IaaS%20(Infrastructure%20as%20a%20Service)%20or%20PaaS%20(Platform%20as%20a%20Service)%20approach%20for%20running%20an%20application%20in%20the%20cloud.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESetting%20up%20a%20self-hosted%20agent%20is%20a%20quite%20straightforward%20operation.%20First%2C%20you%20need%20to%20have%20a%20machine%20that%20you%20want%20to%20use%20as%20an%20agent.%20It%20can%20be%20any%20kind%20of%20machine%3A%20physical%2C%20virtual%2C%20in%20the%20cloud.%20As%20long%20as%20it's%20connected%20to%20Internet%2C%20you're%20good%20to%20go.%20Of%20course%2C%20the%20best%20approach%20is%20to%20use%20a%20dedicated%20virtual%20machine%2C%20where%20you're%20going%20to%20install%20only%20the%20tools%20you%20need%20to%20perform%20the%20compilation.%20In%20my%20case%2C%20I%20opted%20for%20creating%20a%20dedicated%20VM%20on%20Azure.%20If%20you%20have%20a%20Visual%20Studio%20subscription%20linked%20to%20your%20Azure%20account%2C%20you%20can%20choose%20one%20of%20the%20available%20Windows%2010%20Pro%20images%20(in%20my%20case%2C%20I%20chose%20the%20most%20recent%20version%2C%20Windows%2010%201909).%20Otherwise%2C%20you%20can%20choose%20a%20Windows%20Server%202019%20image%20as%20well.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20455px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163520iC6A37F0F28D1FDA0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Windows101909.png%22%20title%3D%22Windows101909.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAs%20size%2C%20keep%20in%20mind%20that%20disk%20speed%20is%20very%20important.%20React%20Native%20for%20Windows%20is%20built%20on%20top%20of%20C%2B%2B%20and%2C%20as%20such%2C%20the%20compilation%20times%20are%20quite%20long.%20If%20you%20choose%20a%20cheap%20storage%20(like%20a%20regular%20HDD%20instead%20of%20SSD)%2C%20the%20compilation%20time%20will%20be%20very%20long.%20My%20suggestion%20is%20to%20go%2C%20at%20least%2C%20with%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EDS2_V2%3C%2FSTRONG%3E%2C%20which%20is%20the%20same%20size%20leveraged%20by%20the%20Microsoft%20hosted%20agents.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163521iA4C4EB75210D9D20%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22VMsize.png%22%20title%3D%22VMsize.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EOnce%20your%20VM%20is%20up%20%26amp%3B%20running%2C%20regardless%20if%20you%20have%20created%20it%20locally%20or%20in%20the%20cloud%2C%20you%20will%20need%20to%20setup%20the%20agent.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22configuring-the-agent%22%20id%3D%22toc-hId--746992874%22%20id%3D%22toc-hId--746992874%22%3EConfiguring%20the%20agent%3C%2FH3%3E%0A%3CP%3EI%20won't%20go%20into%20all%20the%20details%20on%20how%20to%20setup%20a%20self-hosted%20agent%2C%20since%20my%20colleague%20Freist%20has%20explained%20it%20in%20a%20great%20way%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FWindows-Dev-AppConsult%2FDevOps-for-Desktop-How-to-use-Self-Hosted-agent-for-Win10-UWP%2Fba-p%2F774553%22%20target%3D%22_blank%22%3Ein%20the%20following%20blog%20post%3C%2FA%3E.%20Also%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Fagents%2Fv2-windows%3Fview%3Dazure-devops%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethe%20official%20documentation%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Edoes%20a%20great%20job%20in%20explaining%20all%20the%20required%20steps.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20process%20is%20really%20easy.%20You%20just%20need%20to%20download%20a%20package%20from%20the%20Azure%20DevOps%20website%2C%20copy%20it%20over%20on%20your%20machine%20and%20run%20a%20script%20to%20configure%20it.%20The%20script%20will%20ask%20you%20a%20few%20questions%2C%20like%20the%20security%20token%20to%20connect%20your%20Azure%20DevOps%20instance%2C%20the%20work%20folder%2C%20if%20you%20want%20to%20install%20the%20agent%20as%20a%20Windows%20Service%2C%20etc.%20Once%20the%20operation%20is%20complete%2C%20you're%20all%20set.%20The%20agent%20will%20take%20care%20of%20communicating%20with%20Azure%20DevOps%20via%20HTTPS%2C%20to%20exchange%20information%3A%20it%20will%20receive%20the%20tasks%20to%20perform%20and%20it%20will%20send%20back%20the%20produced%20artifacts.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20agent%20is%20up%20%26amp%3B%20running%2C%20you%20can%20start%20installing%20all%20the%20tools%20you%20need%20to%20compile%20our%20React%20Native%20for%20Windows%20project.%20Let's%20see%20them.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22visual-studio-2019%22%20id%3D%22toc-hId--56431400%22%20id%3D%22toc-hId--56431400%22%3EVisual%20Studio%202019%3C%2FH4%3E%0A%3CP%3EAny%20version%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fvisualstudio.microsoft.com%2Fvs%2Fcommunity%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eincluding%20the%20Community%20one%3C%2FA%3E%2C%20will%20be%20fine.%20Just%20make%20sure%20to%20install%20the%20workloads%20and%20components%20required%20by%20React%20Native%2C%20which%20are%20described%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Freact-native-windows%2Fblob%2Fmaster%2Fvnext%2Fdocs%2FGettingStarted.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ein%20the%20official%20documentation%3C%2FA%3E%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWorkloads%0A%3CUL%3E%0A%3CLI%3EUniversal%20Windows%20Platform%20development%0A%3CUL%3E%0A%3CLI%3EEnable%20the%20optional%20C%2B%2B%20(v141)%20Universal%20Windows%20Platform%20tools%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EDesktop%20development%20with%20C%2B%2B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EIndividual%20Components%0A%3CUL%3E%0A%3CLI%3ECompilers%2C%20build%20tools%20and%20runtimes%0A%3CUL%3E%0A%3CLI%3EVC%20v141%20-%20VS%202017%20C%2B%2B%20x64%2Fx86%20build%20tools%20(v14.16)%3C%2FLI%3E%0A%3CLI%3EMSVC%20v141%20-%20VS%202017%20C%2B%2B%20ARM%20build%20tools%20(v14.16)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22chocolatey%22%20id%3D%22toc-hId--1863885863%22%20id%3D%22toc-hId--1863885863%22%3EChocolatey%3C%2FH4%3E%0A%3CP%3EWe%20have%20already%20talked%20about%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fchocolatey.org%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EChocolatey%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fwindows-dev-appconsult%2Fcreate-a-ci-cd-pipeline-for-a-react-native-for-windows%2Fba-p%2F1083253%22%20target%3D%22_blank%22%3Ein%20the%20previous%20post%3C%2FA%3E.%20It's%20a%20popular%20package%20manager%20for%20Windows%20and%20it's%20the%20easiest%20way%20to%20install%20software%20on%20a%20machine%20(especially%20a%20build%20agent)%2C%20since%20everything%20can%20be%20done%20via%20command-line%2C%20without%20requiring%20any%20user%20interaction.%20To%20install%20it%2C%20you%20just%20need%20to%20open%20an%20administrative%20PowerShell%20prompt%20on%20the%20VM%20(the%20easiest%20way%20is%20to%20right%20click%20on%20the%20Start%20button%20and%20choose%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EWindows%20PowerShell%20(Admin)%3C%2FSTRONG%3E)%20and%20launch%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22language-powershell%20hljs%22%3E%3CSPAN%20class%3D%22hljs-built_in%22%3ESet-ExecutionPolicy%3C%2FSPAN%3E%20Bypass%20-Scope%20%3CSPAN%20class%3D%22hljs-keyword%22%3EProcess%3C%2FSPAN%3E%20-Force%3B%20iex%20((%3CSPAN%20class%3D%22hljs-built_in%22%3ENew-Object%3C%2FSPAN%3E%20System.Net.WebClient).DownloadString(%3CSPAN%20class%3D%22hljs-string%22%3E'https%3A%2F%2Fchocolatey.org%2Finstall.ps1'%3C%2FSPAN%3E))%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EOnce%20the%20tool%20is%20installed%2C%20you'll%20be%20able%20to%20install%20applications%20just%20by%20launching%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Echoco%20install%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efollowed%20by%20the%20unique%20identifier%20of%20the%20package.%20You%20can%20explore%20all%20the%20available%20packages%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fchocolatey.org%2Fpackages%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Eon%20the%20official%20website%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22nodejs%22%20id%3D%22toc-hId-623626970%22%20id%3D%22toc-hId-623626970%22%3ENode.js%3C%2FH4%3E%0A%3CP%3EYou%20will%20need%20Node.js%20installed%20on%20the%20machine%2C%20since%20it's%20leveraged%20by%20React%20Native%20to%20handle%20all%20the%20modules.%20Now%20that%20we%20have%20Chocolatey%20on%20the%20machine%2C%20installing%20Node.js%20is%20really%20easy.%20Open%20a%20PowerShell%20prompt%20with%20administrative%20rights%20and%20run%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22language-powershell%20hljs%22%3Echoco%20install%20nodejs.install%20--version%3D%3CSPAN%20class%3D%22hljs-number%22%3E12.9%3C%2FSPAN%3E.%3CSPAN%20class%3D%22hljs-number%22%3E1%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EMake%20sure%20to%20specify%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E--version%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eproperty%2C%20since%2012.9.1%20is%20the%20Node.js%20version%20which%20works%20best%20with%20React%20Native%20at%20the%20time%20of%20writing.%20Different%20versions%20can%20lead%20to%20errors%20during%20the%20bundle%20generation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22yarn%22%20id%3D%22toc-hId--1183827493%22%20id%3D%22toc-hId--1183827493%22%3EYarn%3C%2FH4%3E%0A%3CP%3EWhen%20you%20commit%20your%20React%20Native%20project%20to%20your%20repository%2C%20by%20default%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Enode_modules%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efolder%20is%20ignored.%20These%20are%20libraries%20and%20tools%20which%20haven't%20been%20developed%20by%20us%2C%20so%20it%20wouldn't%20make%20sense%20to%20waste%20space%20on%20our%20repository%20for%20stuff%20that%20can%20be%20easily%20downloaded.%20As%20such%2C%20you%20will%20have%20to%20restore%20all%20the%20dependencies%20before%20running%20the%20compilation.%20The%20best%20way%20to%20do%20is%20to%20leverage%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fyarnpkg.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EYarn%3C%2FA%3E%2C%20a%20popular%20package%20manager%20for%20Node.%20Also%20Yarn%20is%20available%20on%20Chocolatey%2C%20so%20you%20can%20just%20run%20the%20following%20command%20from%20a%20PowerShell%20prompt%20with%20administrative%20rights%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22language-powershell%20hljs%22%3Echoco%20install%20yarn%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22react-native-cli%22%20id%3D%22toc-hId-1303685340%22%20id%3D%22toc-hId-1303685340%22%3EReact%20Native%20CLI%3C%2FH4%3E%0A%3CP%3EDuring%20the%20compilation%20of%20the%20package%2C%20at%20some%20point%20Visual%20Studio%20will%20launch%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Ereact-native%20bundle%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%2C%20which%20bundles%20all%20the%20JavaScript%20files%20together%20so%20that%20you%20don't%20need%20the%20Metro%20packager%20up%20%26amp%3B%20running%20to%20launch%20the%20application.%20In%20order%20to%20achieve%20this%20task%2C%20you%20will%20need%20to%20install%20first%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ereact-native-cli%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Epackage%20globally.%20However%2C%20there's%20a%20catch%2C%20which%20we%20have%20learned%20about%20also%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fwindows-dev-appconsult%2Fcreate-a-ci-cd-pipeline-for-a-react-native-for-windows%2Fba-p%2F1083253%22%20target%3D%22_blank%22%3Ein%20the%20previous%20post%3C%2FA%3E.%20The%20React%20Native%20CLI%20must%20be%20available%20to%20the%20user%20which%20runs%20the%20build%20agent%20service%2C%20otherwise%20Visual%20Studio%20won't%20be%20able%20to%20find%20it.%20In%20case%20of%20a%20hosted%20agent%2C%20we%20learned%20that%20the%20user%20that%20runs%20this%20service%20is%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EVssAdministrator%3C%2FSTRONG%3E.%20What%20about%20self-hosted%20agents%3F%20If%20you%20have%20installed%20the%20agent%20as%20a%20service%20using%20the%20default%20options%2C%20the%20service%20will%20be%20running%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ENetwork%20Service%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Euser%20or%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ELocal%20System%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eaccount%2C%20which%20are%20special%20users%20that%20doesn't%20have%20a%20dedicated%20account.%20As%20such%2C%20you%20have%20two%20options%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EYou%20can%20create%20on%20the%20machine%20a%20dedicated%20user%20with%20administrator%20rights%2C%20which%20will%20be%20dedicated%20to%20the%20agent%20service.%3C%2FLI%3E%0A%3CLI%3EYou%20can%20use%20your%20current%20default%20user%20to%20run%20the%20agent%20service.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ERegardless%20of%20your%20choice%2C%20to%20change%20this%20behavior%20open%20the%20Start%20menu%20and%20type%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22language-plaintext%20hljs%22%3Eservices.msc%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EYou%20will%20open%20a%20window%20that%20will%20list%20all%20the%20services%20installed%20in%20the%20system.%20Look%20for%20the%20agent%20service%2C%20which%20will%20be%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAzure%20Pipelines%20Agent%3C%2FSTRONG%3E%2C%20followed%20by%20the%20a%20string%20composed%20by%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20name%20of%20your%20Azure%20DevOps%20account%3C%2FLI%3E%0A%3CLI%3EThe%20name%20of%20the%20pool%20the%20agent%20belongs%20to%3C%2FLI%3E%0A%3CLI%3EThe%20name%20of%20the%20machine%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EFor%20example%2C%20in%20my%20case%20it's%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAzure%20Pipelines%20Agent%20(mpagani-ms.Default.VSPreviewBuild)%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20957px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163522i3E1CA7F7626B00AC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22AgentName.png%22%20title%3D%22AgentName.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENow%20double%20click%20on%20it%20to%20open%20its%20properties%20and%20move%20to%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ELog%20on%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bsection.%20Select%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EThis%20account%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Boption%20and%2C%20with%20the%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EBrowse%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Bbutton%2C%20search%20for%20the%20user%20on%20the%20machine%20you%20have%20decide%20to%20use%20to%20run%20the%20service.%20In%20my%20case%2C%20I%20chose%20to%20leverage%20my%20current%20user%2C%20which%20is%20called%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eqmatteoq%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3Band%20he%20has%20administrator%20rights.%20You%20will%20need%20to%20provide%20also%20the%20password%20of%20the%20account.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20418px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163523i957BA0B7134939E5%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22ServiceUser.png%22%20title%3D%22ServiceUser.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20have%20setup%20the%20user%20who%20runs%20the%20agent%2C%20you're%20ready%20to%20install%20the%20React%20Native%20CLI.%20Open%20an%20administrative%20prompt%20and%20run%20first%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22language-powershell%20hljs%22%3Enpm%20config%20set%20prefix%20C%3A%5CUsers%5Cqmatteoq%5CAppData%5CRoaming%5Cnpm%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EMake%20sure%20to%20replace%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Eqmatteoq%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewith%20the%20name%20of%20the%20user%20you%20have%20chosen%20to%20run%20the%20service.%20This%20command%20will%20set%20the%20default%20folder%20which%20will%20be%20used%20as%20cache%20for%20NPM%20packages.%20Now%20you%20can%20install%20the%20CLI%20with%20the%20following%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22language-powershell%20hljs%22%3Enpm%20install%20-g%20react-native-cli%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThat's%20it.%20This%20was%20the%20last%20requirement%20to%20install%20on%20the%20machine.%20Now%20we%20can%20go%20back%20to%20the%20Azure%20DevOps%20portal%20and%20create%20our%20pipeline.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22setup-the-cicd-pipeline%22%20id%3D%22toc-hId-1293182236%22%20id%3D%22toc-hId-1293182236%22%3ESetup%20the%20CI%2FCD%20pipeline%3C%2FH3%3E%0A%3CP%3EThe%20process%20of%20creating%20a%20CI%2FCD%20pipeline%20isn't%20very%20different%20from%20the%20one%20we%20did%20in%20the%20previous%20post.%20In%20your%20Azure%20DevOps%20project%20move%20to%20the%20Pipelines%20section%2C%20create%20a%20new%20pipeline%2C%20choose%20where%20your%20source%20code%20is%20hosted%20and%2C%20in%20the%20end%2C%20choose%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EUniversal%20Windows%20Platform%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eas%20last%20template.%20We%20will%20need%2C%20also%20in%20this%20case%2C%20to%20make%20a%20few%20tweaks%2C%20but%20we%20will%20have%20to%20perform%20fewer%20steps.%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fwindows-dev-appconsult%2Fcreate-a-ci-cd-pipeline-for-a-react-native-for-windows%2Fba-p%2F1083253%22%20target%3D%22_blank%22%3EIn%20the%20previous%20post%3C%2FA%3E%2C%20in%20fact%2C%20we%20were%20leveraging%20a%20hosted%20agent%2C%20so%20we%20needed%20to%20install%20every%20time%20the%20missing%20dependencies%2C%20like%20the%20Windows%2010%201903%20SDK%20or%20the%20React%20Native%20CLI.%20In%20our%20scenario%2C%20instead%2C%20we%20have%20already%20installed%20all%20the%20dependencies%20on%20the%20machine%2C%20so%20we%20don't%20need%20to%20install%20them%20every%20time%20we%20perform%20a%20new%20build.%3C%2FP%3E%0A%3CP%3EHere%20is%20how%20your%20YAML%20file%20should%20look%20like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-comment%22%3E%23%20Universal%20Windows%20Platform%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-comment%22%3E%23%20Build%20a%20Universal%20Windows%20Platform%20project%20using%20Visual%20Studio.%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-comment%22%3E%23%20Add%20steps%20that%20test%20and%20distribute%20an%20app%2C%20save%20build%20artifacts%2C%20and%20more%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-comment%22%3E%23%20https%3A%2F%2Faka.ms%2Fyaml%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3Etrigger%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-bullet%22%3E-%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Emaster%3C%2FSPAN%3E%20%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3Epool%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EDefault%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3Evariables%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20solution%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'windows%2F*.sln'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20buildPlatform%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'x64'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20buildConfiguration%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'Release'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20appxPackageDir%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(build.artifactStagingDirectory)%5CAppxPackages%5C%5C'%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3Ename%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E%24(date%3Ayyyy).%24(Month)%24(rev%3A.r).0%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3Esteps%3A%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3E-%20task%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EVersionAPPX%402%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20displayName%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'Version%20MSIX'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20inputs%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20Path%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(Build.SourcesDirectory)'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20VersionNumber%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(Build.BuildNumber)'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20InjectVersion%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-literal%22%3Etrue%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3E-%20script%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eyarn%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Einstall%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3E-%20task%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3ENuGetCommand%402%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20inputs%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20command%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'restore'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20restoreSolution%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'windows%2F*.sln'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20feedsToUse%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'select'%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3E-%20task%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EVSBuild%401%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20inputs%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20solution%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(solution)'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20msbuildArgs%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%2Fp%3AAppxBundlePlatforms%3D%22%24(buildPlatform)%22%20%2Fp%3AAppxPackageDir%3D%22%24(appxPackageDir)%22%20%2Fp%3AAppxBundle%3DNever%20%2Fp%3AUapAppxPackageBuildMode%3DSideloadOnly%20%2Fp%3AAppxPackageSigningEnabled%3Dfalse'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20platform%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(buildPlatform)'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20configuration%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(buildConfiguration)'%3C%2FSPAN%3E%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3E-%20task%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EPublishBuildArtifacts%401%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20inputs%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20PathtoPublish%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(appxPackageDir)'%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20ArtifactName%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'drop'%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ELet's%20see%20which%20are%20the%20major%20differences%20compared%20to%20the%20one%20we%20have%20created%20in%20the%20previous%20post%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EWe%20have%20set%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Epool%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eproperty%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EDefault%3C%2FCODE%3E.%20If%20you%20have%20setup%20the%20agent%20on%20the%20machine%20using%20the%20default%20settings%2C%20it%20will%20belong%20to%20the%20Default%20pool.%20With%20this%20setting%20we're%20telling%20to%20Azure%20DevOps%20that%20we%20don't%20want%20to%20use%20a%20hosted%20agent%2C%20but%20our%20custom%20one.%3C%2FLI%3E%0A%3CLI%3EWe%20don't%20need%20anymore%20to%20install%20Yarn%2C%20the%20Windows%201903%20SDK%20and%20the%20React%20Native%20CLI%20at%20every%20build.%20We%20have%20already%20installed%20them%20when%20we%20have%20configured%20the%20machine.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EThe%20rest%20of%20the%20steps%20are%20the%20same%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EWe%20change%20the%20build%20number%2C%20so%20that%20it's%20compliant%20with%20the%20rules%20required%20by%20a%20MSIX%20manifest%20to%20define%20a%20version%20number%20(%3CSTRONG%3Ex.y.z.0%3C%2FSTRONG%3E).%20Then%2C%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EVersionAPPX%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Etask%2C%20we%20inject%20it%20in%20the%20manifest%20of%20your%20application.%3C%2FLI%3E%0A%3CLI%3EWe%20restore%20all%20the%20Node%20dependencies%20with%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Eyarn%20install%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand.%3C%2FLI%3E%0A%3CLI%3EWe%20restore%20the%20NuGet%20packages%20required%20by%20React%20Native%20for%20Windows.%3C%2FLI%3E%0A%3CLI%3EWe%20build%20the%20project%20using%20Visual%20Studio.%3C%2FLI%3E%0A%3CLI%3EWe%20publish%20the%20build%20artifacts%20on%20Azure%20DevOps%2C%20so%20that%20other%20pipelines%20(like%20a%20release%20pipeline)%20can%20pick%20it%20to%20perform%20additional%20tasks%2C%20like%20performing%20a%20deployment.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22thats-all-folks%22%20id%3D%22toc-hId--514272227%22%20id%3D%22toc-hId--514272227%22%3EThat's%20all%20folks!%3C%2FH3%3E%0A%3CP%3EThat's%20it!%20Now%20we%20have%20a%20CI%20pipeline%20that%20can%20automatically%20build%20a%20new%20MSIX%20package%20every%20time%20we%20commit%20some%20code%20to%20the%20repository%20of%20our%20React%20Native%20project%20which%20uses%20one%20or%20more%20native%20modules%20for%20Windows.%20Now%20we%20can%20build%20a%20release%20pipeline%2C%20which%20will%20take%20care%20of%20deploying%20the%20MSIX%20package%20we%20have%20just%20created%20to%20our%20users%3A%20we%20can%20upload%20it%20on%20the%20Microsoft%20Store%2C%20we%20can%20upload%20it%20on%20a%20website%20or%20cloud%20storage%20to%20make%20it%20available%20through%20sideloading%2C%20etc.%20You%20can%20learn%20more%20about%20this%20in%20the%20last%20chapter%20of%20my%20latest%20e-book%20titled%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwww.syncfusion.com%2Febooks%2Fmsix-succinctly%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EMSIX%20Succinctly%3C%2FA%3E%2C%20which%20has%20been%20published%20and%20released%20for%20free%20by%20Syncfusion%2C%20or%20in%20Exercise%206%20of%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FAppConsult-WinAppsModernizationWorkshop%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EWindows%20application%20modernization%20workshop%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ebuilt%20by%20my%20team.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHappy%20coding!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1085473%22%20slang%3D%22en-US%22%3E%3CP%3ELet's%20learn%20how%20to%20enable%20CI%2FCD%20in%20a%20React%20Native%20for%20Windows%20project%20which%20uses%20native%20modules%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Jan 02 2020 01:25 AM
Updated by: