%3CLINGO-SUB%20id%3D%22lingo-sub-1083253%22%20slang%3D%22en-US%22%3ECreate%20a%20CI%2FCD%20pipeline%20for%20a%20React%20Native%20for%20Windows%20application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1083253%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EUpdate%20on%202nd%20January%202020%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Freact-native-windows%2Fissues%2F3810%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ebug%3C%2FA%3E%20described%20in%20the%20post%20which%20prevented%20the%20Bundle%20folder%20to%20be%20included%20in%20the%20final%20AppX%20%2F%20MISX%20package%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Freact-native-windows%2Fpull%2F3821%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehas%20been%20fixed%3C%2FA%3E.%20As%20such%2C%20the%20step%20in%20the%20pipeline%20to%20workaround%20the%20bug%20has%20been%20removed%2C%20since%20it%20isn't%20needed%20anymore.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20working%20for%20a%20while%20on%20React%20Native%20for%20Windows%2C%20I've%20started%20pretty%20soon%20to%20research%20how%20to%20build%20a%20CI%2FCD%20pipeline%20for%20such%20a%20project.%20I'm%20a%20big%20fan%20of%20Azure%20DevOps%20and%20having%20an%20automated%20cycle%20where%20I%20can%20continuously%20deliver%20new%20versions%20of%20my%20application%20just%20by%20committing%20new%20code%20to%20my%20repository%20is%20priceless%20for%20me.%20Now%20it's%20a%20good%20time%20to%20start%20playing%20with%20CI%2FCD%20for%20React%20Native%20for%20Windows%3A%20as%20I%20have%20mentioned%20at%20the%20end%20of%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%3Emy%20previous%20post%20about%20building%20native%20modules%3C%2FA%3E%2C%20now%20you%20can%20build%20self-contained%20bundles%20for%20Windows%2C%20which%20don't%20require%20the%20Metro%20packager%20to%20be%20up%20%26amp%3B%20running.%20It's%20enough%20to%20start%20the%20traditional%20process%20in%20Visual%20Studio%20to%20create%20an%20app%20package%20and%20choose%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERelease%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Econfiguration%20mode%20to%20get%20an%20AppX%20%2F%20MSIX%20package%20that%20can%20be%20published%20on%20the%20Microsoft%20Store%2C%20side-loaded%2C%20deployed%20in%20an%20enterprise%20using%20SSCM%20or%20Intune%2C%20etc.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20when%20you%20start%20exploring%20this%20option%2C%20you%20face%20a%20few%20challenges%2C%20since%20the%20hosted%20agents%20provided%20by%20Azure%20DevOps%20miss%20some%20of%20the%20requirements%20to%20compile%20the%20various%20projects%20included%20in%20the%20React%20Native%20for%20Windows%20implementation.%20Let's%20see%20how%20to%20properly%20setup%20our%20pipeline.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22create-the-pipeline%22%20id%3D%22toc-hId-1060400025%22%20id%3D%22toc-hId-1060400025%22%3ECreate%20the%20pipeline%3C%2FH3%3E%0A%3CP%3EThe%20first%20step%2C%20as%20always%2C%20is%20to%20have%20the%20source%20code%20of%20your%20React%20Native%20project%20committed%20on%20a%20source%20control%20repository.%20In%20my%20case%20I%20hosted%20it%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fqmatteoq%2FNavigationSample%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eon%20GitHub%3C%2FA%3E%2C%20but%20you%20can%20choose%20Azure%20Repos%20or%20any%20other%20Git%20provider.%20Then%20you%20need%20to%20move%20to%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EPipelines%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esection%20of%20your%20Azure%20DevOps%20project%20(create%20one%20if%20you%20don't%20have%20it)%20and%20click%20on%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ECreate%20pipeline%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%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163365iF1673A266195B310%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22CreatePipeline.png%22%20title%3D%22CreatePipeline.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20first%20step%2C%20choose%20the%20repository%20where%20your%20code%20is%20hosted.%20As%20second%20step%2C%20you%20will%20be%20asked%20for%20a%20starting%20template%20for%20the%20YAML%20file%2C%20which%20defines%20the%20tasks%20that%20our%20pipeline%20will%20have%20to%20follow.%20Thanks%20to%20YAML%20you%20can%20enable%20what%20is%20called%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EInfrastructure%20As%20Code%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eapproach%2C%20which%20allows%20to%20provision%20hardware%20resources%20using%20a%20configuration%20file%20rather%20than%20interactive%20tools%20like%20a%20wizard.%20The%20advantage%20of%20this%20approach%20is%20that%20the%20configuration%20of%20your%20infrastructure%20(in%20this%20case%2C%20a%20build%20machine)%20becomes%20part%20of%20your%20project%3A%20it%20can%20be%20committed%20to%20the%20repository%2C%20it%20can%20be%20versioned%2C%20it%20can%20be%20easily%20replicated.%3C%2FP%3E%0A%3CP%3EThe%20best%20template%20for%20our%20scenario%20is%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EUniversal%20Windows%20Platform%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eone%2C%20since%20React%20Native%20for%20Windows%20generates%2C%20under%20the%20hood%2C%20a%20UWP%20application.%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%20667px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163366iB2726988AECCD4E3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22UWPTemplate.png%22%20title%3D%22UWPTemplate.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20the%20default%20YAML%20that%20gets%20created%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-20%22%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%0A%0A%3CSPAN%20class%3D%22hljs-attr%22%3Epool%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20vmImage%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'windows-latest'%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'**%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'x86%7Cx64%7CARM'%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%3Esteps%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E-%20task%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3ENuGetToolInstaller%401%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%20restoreSolution%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(solution)'%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%20platform%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'x86'%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%20configuration%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'%24(buildConfiguration)'%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%3DAlways%20%2Fp%3AUapAppxPackageBuildMode%3DStoreUpload'%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ENow%20we%20need%20to%20make%20a%20few%20changes.%20Let's%20see%20them%2C%20step%20by%20step.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22choose-the-right-hosted-agent%22%20id%3D%22toc-hId-1750961499%22%20id%3D%22toc-hId-1750961499%22%3EChoose%20the%20right%20hosted%20agent%3C%2FH4%3E%0A%3CP%3EBy%20default%2C%20the%20Universal%20Windows%20Platform%20template%20leverages%20the%20latest%20Windows%20hosted%20agent%2C%20which%20ships%20with%20Visual%20Studio%202019.%20However%2C%20there's%20a%20catch%20in%20our%20scenario.%20Many%20of%20the%20C%2B%2B%20projects%20involved%20in%20the%20React%20Native%20implementation%20are%20leveraging%20the%20C%2B%2B%20v141%20toolset%20platform%2C%20which%20belongs%20to%20Visual%20Studio%202017.%20The%20Visual%20Studio%20installer%20offers%20you%20the%20option%20to%20install%20the%20v141%20toolset%20in%20Visual%20Studio%202019%20but%2C%20unfortunately%2C%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ewindows-latest%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ehosted%20agent%20doesn't%20include%20it.%20As%20such%2C%20we%20need%20to%20fallback%20to%20the%20hosted%20agent%20with%20Visual%20Studio%202017%2C%20by%20setting%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EvmImage%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eproperty%20of%20the%20YAML%20file%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Evs2017-win2016%3C%2FCODE%3E%2C%20as%20in%20the%20following%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-58%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3Epool%3A%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E%20%20%20%20vmImage%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'vs2017-win2016'%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CH4%20id%3D%22toc-hId--56492964%22%20id%3D%22toc-hId--56492964%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22update-the-configuration-settings%22%20id%3D%22toc-hId--1863947427%22%20id%3D%22toc-hId--1863947427%22%3EUpdate%20the%20configuration%20settings%3C%2FH4%3E%0A%3CP%3EThere%20are%20a%20few%20changes%20to%20make%20here%20compared%20to%20the%20default%20configuration.%20The%20most%20important%20one%20is%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Esolution%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eparameter%2C%20which%20by%20default%20is%20set%20to%20compile%20every%20solution%20included%20in%20the%20repository.%20However%2C%20React%20Native%20for%20Windows%20doesn't%20ship%20as%20a%20library%20or%20a%20NuGet%20package%2C%20but%20the%20whole%20source%20code%20is%20included%20as%20a%20Node%20module.%20As%20such%2C%20we%20need%20to%20specify%20that%20we%20want%20to%20compile%20only%20the%20solution%20which%20is%20included%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ewindows%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efolder%2C%20which%20is%20the%20one%20that%20will%20generate%20the%20final%20AppX%20%2F%20MSIX%20package.%20As%20per%20the%20build%20platform%2C%20you're%20free%20to%20choose%20the%20ones%20you%20prefer%3A%20since%20React%20Native%20for%20Windows%20generates%20a%20Universal%20Windows%20Platform%20application%2C%20it%20supports%20x86%2C%20x64%20and%20ARM.%20The%20build%20configuration%2C%20instead%2C%20must%20be%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERelease%3C%2FSTRONG%3E%3A%20as%20we%20have%20learned%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%20the%20previous%20post%3C%2FA%3E%2C%20this%20is%20the%20compilation%20mode%20which%20generates%20a%20self-contained%20application.%3C%2FP%3E%0A%3CP%3EThis%20is%20how%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Evariables%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esection%20of%20our%20YAML%20file%20should%20look%20like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-71%22%20class%3D%22language-yaml%20hljs%22%3E%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%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22set-the-version-number%22%20id%3D%22toc-hId-623565406%22%20id%3D%22toc-hId-623565406%22%3ESet%20the%20version%20number%3C%2FH4%3E%0A%3CP%3EThis%20isn't%20specific%20for%20React%20Native%2C%20but%20it%20applies%20to%20every%20application%20packaged%20as%20MSIX.%20If%20you%20want%20to%20have%20a%20reliable%20CI%20%2F%20CD%20pipeline%2C%20you%20must%20increase%20the%20version%20number%20at%20every%20build.%20Regardless%20if%20you%20choose%20to%20publish%20the%20app%20on%20the%20Microsoft%20Store%20or%20to%20deploy%20it%20in%20another%20way%2C%20an%20update%20must%20always%20have%20a%20higher%20version%20number%20than%20the%20previous%20release.%3C%2FP%3E%0A%3CP%3EThe%20easiest%20way%20to%20achieve%20this%20task%20is%20to%20leverage%20the%20build%20number%2C%20since%20Azure%20DevOps%20automatically%20generates%20a%20new%20one%20at%20every%20build.%20However%2C%20the%20default%20one%20isn't%20a%20good%20fit%20for%20a%20packaged%20application.%20By%20default%2C%20in%20fact%2C%20Azure%20DevOps%20uses%20the%20following%20rule%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-84%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-string%22%3E%24(Date%3AyyyyMMdd).%24(Rev%3Ar)%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ewhich%20is%20translated%20to%20a%20build%20number%20like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-90%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-number%22%3E20191222.12%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIf%20you%20have%20some%20experience%20with%20packaged%20applications%2C%20you'll%20immediately%20realize%20that%20this%20number%20won't%20work.%20The%20manifest%20of%20an%20AppX%20%2F%20MSIX%20package%2C%20in%20fact%2C%20requires%20the%20version%20number%20to%20follow%20the%20rule%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ex.y.z.0%3C%2FSTRONG%3E%2C%20so%20something%20like%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-96%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-number%22%3E2019.12%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-number%22%3E.22%3C%2FSPAN%3E%3CSPAN%20class%3D%22hljs-number%22%3E.0%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAs%20such%2C%20we%20need%20to%20change%20the%20default%20build%20number%2C%20by%20adding%20the%20following%20entry%20in%20the%20YAML%20file%2C%20before%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Esteps%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esection%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-102%22%20class%3D%22language-yaml%20hljs%22%3E%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%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThe%20next%20step%20is%20to%20inject%20this%20build%20number%20in%20the%20manifest%20of%20our%20application.%20The%20easiest%20way%20to%20do%20it%20is%20to%20install%2C%20in%20our%20Azure%20DevOps%20account%2C%20a%203rd%20party%20extension%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fmarketplace.visualstudio.com%2Fitems%3FitemName%3DrichardfennellBM.BM-VSTS-Versioning-Task%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EManifest%20Versioning%20Build%20Task%3C%2FA%3E%2C%20developed%20by%20Richard%20Fennell.%20Once%20we%20have%20added%20it%2C%20we%20can%20simply%20add%2C%20as%20fist%20task%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Esteps%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Esection%2C%20the%20following%20entry%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-109%22%20class%3D%22language-yaml%20hljs%22%3E%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%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThis%20task%20will%20simply%20take%20the%20build%20number%20(stored%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%24(Build.BuildNumber)%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evariable)%20and%20set%20it%20inside%20the%20manifest%20of%20our%20application.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22use-the-right-version-of-nodejs%22%20id%3D%22toc-hId--1183889057%22%20id%3D%22toc-hId--1183889057%22%3EUse%20the%20right%20version%20of%20Node.js%3C%2FH4%3E%0A%3CP%3EThe%20hosted%20agent%20comes%20with%20Node.js%20already%20installed.%20However%2C%20React%20Native%20requires%20a%20specific%20version%20to%20work%20properly.%20Using%20a%20newer%20version%20can%20lead%20to%20errors%20during%20the%20bundling%20process.%20As%20such%2C%20we%20need%20to%20add%20a%20task%20to%20install%20and%20set%20the%20correct%20Node.js%20version%20as%20default%20on%20the%20hosted%20agent%2C%20which%20is%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E12.9.1%3C%2FSTRONG%3E%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-124%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3E-%20task%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3EUseNode%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%20version%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3E'12.9.1'%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22install-the-windows-10-1903-sdk%22%20id%3D%22toc-hId-1303623776%22%20id%3D%22toc-hId-1303623776%22%3EInstall%20the%20Windows%2010%201903%20SDK%3C%2FH4%3E%0A%3CP%3EReact%20Native%20for%20Windows%20projects%20are%20compiled%20using%2C%20as%20target%20SDK%2C%20the%201903%20(build%2018836)%20one.%20However%2C%20since%20this%20version%20is%20fairly%20new%2C%20it's%20included%20only%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ewindows-latest%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ehosted%20agent%20and%20not%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Evs2017-win2016%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eone%20we're%20using.%20As%20such%2C%20if%20we%20want%20to%20avoid%20compilation%20errors%2C%20we%20need%20to%20install%20the%20SDK%20first%20on%20the%20hosted%20agent.%20The%20easiest%20way%20to%20do%20it%20is%20to%20leverage%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%2C%20the%20popular%20package%20manager%20for%20Windows.%20Think%20of%20it%20like%20NuGet%2C%20but%20for%20Windows%20applications%20instead%20of%20development%20libraries.%20Among%20the%20many%20packages%20it%20offers%2C%20we%20can%20find%20also%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fchocolatey.org%2Fpackages%2Fwindows-sdk-10-version-1903-all%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EWindows%2010%201903%20SDK%3C%2FA%3E.%20Chocolatey%20is%20already%20installed%20on%20every%20Windows%20hosted%20agent%2C%20so%20you%20just%20need%20to%20add%20the%20following%20task%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-133%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3E-%20script%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Echoco%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Einstall%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ewindows-sdk-10-version-1903-all%3C%2FSPAN%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22install-the-modules-used-by-our-react-native-application%22%20id%3D%22toc-hId--503830687%22%20id%3D%22toc-hId--503830687%22%3EInstall%20the%20modules%20used%20by%20our%20React%20Native%20application%3C%2FH4%3E%0A%3CP%3EBy%20default%2C%20the%20dependencies%20of%20a%20React%20Native%20application%20are%20not%20committed%20inside%20the%20repository%2C%20but%20they%20are%20restored%20the%20first%20time%20you%20build%20the%20application.%20This%20is%20a%20standard%20approach.%20This%20isn't%20code%20we%20have%20written%2C%20so%20it%20wouldn't%20make%20sense%20to%20increase%20the%20size%20of%20our%20repository%20for%20files%20that%20can%20be%20easily%20downloaded%20from%20Internet.%20We%20see%20the%20same%2C%20for%20example%2C%20with%20NuGet%20packages%20leveraged%20by%20.NET%20applications.%20As%20such%2C%20before%20building%20our%20project%2C%20we%20need%20to%20make%20sure%20that%20all%20the%20modules%20are%20downloaded%20and%20installed%20on%20the%20hosted%20agent.%20To%20achieve%20this%20goal%20we%20can%20use%20Yarn%2C%20which%20is%20installed%20as%20well%20on%20every%20hosted%20agent.%20As%20such%2C%20we%20just%20need%20to%20add%20the%20following%20task%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-141%22%20class%3D%22language-yaml%20hljs%22%3E%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%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22install-the-react-native-cli%22%20id%3D%22toc-hId-1983682146%22%20id%3D%22toc-hId-1983682146%22%3EInstall%20the%20React%20Native%20CLI%3C%2FH4%3E%0A%3CP%3EAt%20some%20point%2C%20during%20the%20creation%20of%20the%20MSIX%20package%2C%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%20takes%20care%20of%20bundling%20all%20the%20JavaScript%20files%20in%20a%20binary%20file%2C%20so%20that%20the%20application%20can%20run%20without%20the%20Metro%20packager.%20The%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Ereact-native%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecommand%20is%20part%20of%20the%20React%20Native%20CLI%2C%20which%20isn't%20installed%20by%20default%20on%20the%20hosted%20agent.%20We%20need%20to%20install%20it%20first%20as%20a%20global%20tool%2C%20using%20NPM.%20However%2C%20there's%20a%20catch.%20When%20you%20install%20a%20package%20as%20global%20with%20NPM%2C%20it's%20installed%20only%20for%20the%20current%20user.%20The%20hosted%20agent%2C%20instead%2C%20performs%20all%20the%20tasks%20using%20a%20service%20which%20runs%20using%20a%20dedicated%20account%2C%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EVssAdministrator%3C%2FSTRONG%3E.%20As%20such%2C%20we%20need%20to%20install%20the%20React%20Native%20CLI%20for%20this%20user%2C%20otherwise%20the%20Visual%20Studio%20build%20will%20fail%20because%20it%20won't%20find%20it.%3C%2FP%3E%0A%3CP%3ENPM%20supports%20setting%20the%20folder%20where%20to%20install%20global%20packages%2C%20by%20using%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Econfig%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eparameter.%20Here%20are%20the%20tasks%20we%20need%20to%20launch%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-151%22%20class%3D%22language-yaml%20hljs%22%3E%3CSPAN%20class%3D%22hljs-attr%22%3E-%20script%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enpm%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Econfig%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eset%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Eprefix%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-attr%22%3EC%3A%5CUsers%5CVssAdministrator%5CAppData%5CRoaming%5Cnpm%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22hljs-attr%22%3E-%20script%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Enpm%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Einstall%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-bullet%22%3E-g%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22hljs-string%22%3Ereact-native-cli%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EThe%20first%20script%20sets%2C%20as%20installation%20folder%20for%20NPM%20packages%2C%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAppData%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efolder%20which%20belongs%20to%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EVssAdministrator%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Euser.%20The%20second%20script%2C%20instead%2C%20installs%20the%20React%20Native%20CLI%20in%20that%20folder.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22restore-the-nuget-packages%22%20id%3D%22toc-hId-176227683%22%20id%3D%22toc-hId-176227683%22%3ERestore%20the%20NuGet%20packages%3C%2FH4%3E%0A%3CP%3EBefore%20moving%20on%20we%20need%20to%20restore%20the%20NuGet%20packages.%20Many%20of%20the%20React%20Native%20for%20Windows%20projects%2C%20in%20fact%2C%20have%20dependencies%20on%20NuGet%20packages%20which%20are%20required%20by%20the%20whole%20solution%20to%20build.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-161%22%20class%3D%22language-yaml%20hljs%22%3E%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%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAs%20you%20can%20notice%2C%20also%20in%20this%20case%20we%20specify%20that%20we%20want%20to%20restore%20only%20the%20NuGet%20packages%20referenced%20by%20the%20main%20solution%2C%20which%20is%20stored%20inside%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ewindows%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efolder.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22build-the-visual-studio-solution%22%20id%3D%22toc-hId--400356181%22%20id%3D%22toc-hId--400356181%22%3EBuild%20the%20Visual%20Studio%20solution%3C%2FH4%3E%0A%3CP%3ENow%20we%20can%20finally%20build%20the%20Visual%20Studio%20solution.%20Here%20we%20don't%20have%20to%20make%20too%20many%20changes%20to%20the%20default%20settings.%20This%20is%20the%20task%20I'm%20using%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-184%22%20class%3D%22language-yaml%20hljs%22%3E%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%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIn%20my%20case%2C%20I%20opted%20to%20generate%20a%20MSIX%20package%20and%20not%20a%20bundle%20(%3CCODE%3E%2Fp%3AAppxBundle%3DNever%3C%2FCODE%3E)%20and%20to%20use%20it%20for%20sideloading%20(%3CCODE%3E%2Fp%3AUapAppxPackageBuildMode%3DSideloadOnly%3C%2FCODE%3E).%20If%20you%20want%20to%20generate%20a%20bundle%20(which%20is%20suggested%20if%20you%20want%20to%20support%20multiple%20CPU%20architectures%20or%20you%20have%20lot%20of%20graphical%20assets)%2C%20just%20set%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%2Fp%3AAppBundle%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eparameter%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EAlways%3C%2FCODE%3E.%20And%20if%20you%20want%20to%20publish%20your%20application%20on%20the%20Microsoft%20Store%2C%20just%20leave%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%2Fp%3AUapAppxPackageBuildMode%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eparameter%20set%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EStoreUpload%3C%2FCODE%3E.%20The%20only%20parameter%20which%20I%20strongly%20encourage%20to%20add%20is%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E%2Fp%3AAppxPackageSigningEnabled%3Dfalse%3C%2FCODE%3E%2C%20which%20will%20disable%20package%20signing%20during%20the%20build%20process.%20If%20you%20want%20to%20publish%20your%20application%20on%20the%20Microsoft%20Store%2C%20you%20don't%20need%20to%20digitally%20sign%20the%20package%20since%20the%20Store%20will%20do%20it%20for%20you.%20If%2C%20instead%2C%20you%20want%20to%20release%20it%20in%20other%20ways%2C%20you%20have%20to%20sign%20it%20but%20doing%20it%20during%20the%20build%20process%20performed%20by%20Visual%20Studio%20isn't%20considered%20a%20best%20practice.%20You%20would%20need%2C%20in%20fact%2C%20to%20upload%20the%20certificate%20on%20your%20repository%2C%20leaving%20you%20vulnerable%20to%20identity%20theft.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22the-deployment%22%20id%3D%22toc-hId-1958073933%22%20id%3D%22toc-hId-1958073933%22%3EThe%20deployment%3C%2FH3%3E%0A%3CP%3ECongratulations!%20Now%2C%20every%20time%20you'll%20commit%20new%20code%20to%20the%20repository%2C%20a%20build%20will%20be%20triggered%20and%20the%20hosted%20agent%20will%20create%20a%20new%20MSIX%20package%20with%20the%20latest%20version.%20That's%20the%20Continuous%20Integration%20part%20of%20our%20DevOps%20story.%20What%20about%20the%20Continuous%20Deployment%3F%20Once%20we%20have%20a%20MSIX%20package%2C%20we%20need%20to%20deploy%20it%20so%20that%20our%20users%20can%20get%20the%20most%20up-to-date%20version.%20We%20have%20different%20options%3A%20we%20can%20publish%20the%20package%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fpublish%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eon%20the%20Microsoft%20Store%3C%2FA%3E%3B%20or%20we%20can%20leverage%20a%20technology%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmsix%2Fapp-installer%2Fapp-installer-file-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EApp%20Installer%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20deploy%20the%20package%20on%20a%20website%20and%20enable%20automatic%20updates%20from%20there.%3C%2FP%3E%0A%3CP%3ETo%20achieve%20this%20goal%20you're%20going%20to%20build%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdevops%2Fpipelines%2Frelease%2F%3Fview%3Dazure-devops%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ea%20release%20pipeline%3C%2FA%3E%2C%20which%20will%20allow%20you%20to%20deploy%20your%20application%20in%20multiple%20stages.%20Azure%20DevOps%20offer%20many%20built-in%20tasks%20which%20makes%20the%20deployment%20easier%3A%20you%20have%20tasks%20to%20connect%20to%20the%20Microsoft%20Store%3B%20tasks%20to%20digitally%20sign%20the%20package%20with%20a%20certificate%3B%20tasks%20to%20copy%20the%20package%20on%20an%20Azure%20Storage%3B%20etc.%3C%2FP%3E%0A%3CP%3EI%20won't%20explain%20all%20the%20details%20in%20this%20article.%20You%20can%20find%20all%20the%20information%20about%20the%20various%20options%20you%20have%20and%20how%20to%20implement%20them%20in%20the%20last%20chapter%20of%20my%20recently%20released%20e-book%2C%20called%20MSIX%20Succinctly%2C%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%3Ewhich%20is%20available%20for%20free%20thanks%20to%20Syncfusion%3C%2FA%3E.%20Alternatively%2C%20this%20topic%20is%20covered%20also%20by%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%20applications%20modernization%20workshop%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ethat%20my%20team%20has%20built.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22whats-next%22%20id%3D%22toc-hId-150619470%22%20id%3D%22toc-hId-150619470%22%3EWhat's%20next%3F%3C%2FH3%3E%0A%3CP%3EIn%20this%20post%20we%20have%20learned%20how%20to%20create%20a%20CI%2FCD%20pipeline%20for%20a%20React%20Native%20for%20Windows%20project.%20But%20there's%20a%20catch.%20Let's%20say%20you%20have%20a%20project%20which%20includes%20some%20custom%20native%20modules%20you%20have%20built%2C%20following%20the%20approach%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%3Edescribed%20in%20my%20previous%20post%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EIf%20you%20setup%20a%20pipeline%20with%20the%20guidance%20described%20in%20this%20article%2C%20you'll%20start%20to%20hit%20a%20series%20of%20errors%20like%20the%20following%20ones%20during%20the%20Visual%20Studio%20build%20task%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20id%3D%22pragma-line-217%22%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%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMicrosoft.ReactNative.SharedManaged%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eproject%2C%20which%20contains%20the%20implementation%20of%20the%20various%20classes%20and%20attributes%20which%20make%20easier%20to%20turn%20a%20class%20into%20a%20native%20module%20for%20React%20Native%2C%20leverages%20many%20features%20of%20the%20C%23%20language%20that%20has%20been%20added%20after%20the%207.0%20release.%20Many%20of%20these%20features%20require%20Visual%20Studio%202019%2C%20while%20our%20hosted%20agent%20is%20running%20Visual%20Studio%202017.%3C%2FP%3E%0A%3CP%3EUnfortunately%2C%20as%20we%20have%20learned%20in%20the%20beginning%2C%20due%20to%20the%20requirement%20of%20supporting%20the%20v141%20C%2B%2B%20platform%20toolset%20we%20can't%20just%20switch%20our%20pipeline%20to%20use%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3Ewindows-latest%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ehosted%20agent.%20As%20such%2C%20we%20need%20to%20build%20a%20self-hosted%20agent%20with%20all%20our%20requirements.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%20that's%20food%20for%20the%20next%20blog%20post%20%3D)%3C%2Fimg%3E%20In%20the%20meantime%2C%20you%20can%20review%20the%20final%20version%20of%20the%20pipeline%20we%20have%20built%20in%20a%20sample%20React%20Native%20project%20I%20put%20together%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fqmatteoq%2FNavigationSample%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eon%20GitHub%3C%2FA%3E.%20The%20repository%20contains%20a%20file%20called%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fqmatteoq%2FNavigationSample%2Fblob%2Fmaster%2Fazure-pipelines.yml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eazure-pipelines.yml%3C%2FA%3E%2C%20which%20contains%20the%20full%20YAML%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHappy%20coding!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1083253%22%20slang%3D%22en-US%22%3E%3CP%3ELearn%20how%20you%20can%20enable%20CI%2FCD%20for%20a%20React%20Native%20for%20Windows%20application%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

Update on 2nd January 2020

The bug described in the post which prevented the Bundle folder to be included in the final AppX / MISX package has been fixed. As such, the step in the pipeline to workaround the bug has been removed, since it isn't needed anymore.

 

After working for a while on React Native for Windows, I've started pretty soon to research how to build a CI/CD pipeline for such a project. I'm a big fan of Azure DevOps and having an automated cycle where I can continuously deliver new versions of my application just by committing new code to my repository is priceless for me. Now it's a good time to start playing with CI/CD for React Native for Windows: as I have mentioned at the end of my previous post about building native modules, now you can build self-contained bundles for Windows, which don't require the Metro packager to be up & running. It's enough to start the traditional process in Visual Studio to create an app package and choose the Release configuration mode to get an AppX / MSIX package that can be published on the Microsoft Store, side-loaded, deployed in an enterprise using SSCM or Intune, etc.

 

However, when you start exploring this option, you face a few challenges, since the hosted agents provided by Azure DevOps miss some of the requirements to compile the various projects included in the React Native for Windows implementation. Let's see how to properly setup our pipeline.

 

Create the pipeline

The first step, as always, is to have the source code of your React Native project committed on a source control repository. In my case I hosted it on GitHub, but you can choose Azure Repos or any other Git provider. Then you need to move to the Pipelines section of your Azure DevOps project (create one if you don't have it) and click on Create pipeline.

 

CreatePipeline.png

 

As first step, choose the repository where your code is hosted. As second step, you will be asked for a starting template for the YAML file, which defines the tasks that our pipeline will have to follow. Thanks to YAML you can enable what is called the Infrastructure As Code approach, which allows to provision hardware resources using a configuration file rather than interactive tools like a wizard. The advantage of this approach is that the configuration of your infrastructure (in this case, a build machine) becomes part of your project: it can be committed to the repository, it can be versioned, it can be easily replicated.

The best template for our scenario is the Universal Windows Platform one, since React Native for Windows generates, under the hood, a UWP application.

 

UWPTemplate.png

 

This is the default YAML that gets created:

 

# 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:
  vmImage: 'windows-latest'

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

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    platform: 'x86'
    solution: '$(solution)'
    configuration: '$(buildConfiguration)'
    msbuildArgs: '/p:AppxBundlePlatforms="$(buildPlatform)" /p:AppxPackageDir="$(appxPackageDir)" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload'

Now we need to make a few changes. Let's see them, step by step.

 

Choose the right hosted agent

By default, the Universal Windows Platform template leverages the latest Windows hosted agent, which ships with Visual Studio 2019. However, there's a catch in our scenario. Many of the C++ projects involved in the React Native implementation are leveraging the C++ v141 toolset platform, which belongs to Visual Studio 2017. The Visual Studio installer offers you the option to install the v141 toolset in Visual Studio 2019 but, unfortunately, the windows-latest hosted agent doesn't include it. As such, we need to fallback to the hosted agent with Visual Studio 2017, by setting the vmImage property of the YAML file to vs2017-win2016, as in the following example:

 

pool:
    vmImage: 'vs2017-win2016'

 

Update the configuration settings

There are a few changes to make here compared to the default configuration. The most important one is the solution parameter, which by default is set to compile every solution included in the repository. However, React Native for Windows doesn't ship as a library or a NuGet package, but the whole source code is included as a Node module. As such, we need to specify that we want to compile only the solution which is included in the windows folder, which is the one that will generate the final AppX / MSIX package. As per the build platform, you're free to choose the ones you prefer: since React Native for Windows generates a Universal Windows Platform application, it supports x86, x64 and ARM. The build configuration, instead, must be Release: as we have learned in the previous post, this is the compilation mode which generates a self-contained application.

This is how the variables section of our YAML file should look like:

 

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

 

Set the version number

This isn't specific for React Native, but it applies to every application packaged as MSIX. If you want to have a reliable CI / CD pipeline, you must increase the version number at every build. Regardless if you choose to publish the app on the Microsoft Store or to deploy it in another way, an update must always have a higher version number than the previous release.

The easiest way to achieve this task is to leverage the build number, since Azure DevOps automatically generates a new one at every build. However, the default one isn't a good fit for a packaged application. By default, in fact, Azure DevOps uses the following rule:

 

$(Date:yyyyMMdd).$(Rev:r)

which is translated to a build number like:

 

20191222.12

If you have some experience with packaged applications, you'll immediately realize that this number won't work. The manifest of an AppX / MSIX package, in fact, requires the version number to follow the rule x.y.z.0, so something like:

 

2019.12.22.0

As such, we need to change the default build number, by adding the following entry in the YAML file, before the steps section:

 

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

The next step is to inject this build number in the manifest of our application. The easiest way to do it is to install, in our Azure DevOps account, a 3rd party extension called Manifest Versioning Build Task, developed by Richard Fennell. Once we have added it, we can simply add, as fist task in the steps section, the following entry:

 

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

This task will simply take the build number (stored in the $(Build.BuildNumber) variable) and set it inside the manifest of our application.

 

Use the right version of Node.js

The hosted agent comes with Node.js already installed. However, React Native requires a specific version to work properly. Using a newer version can lead to errors during the bundling process. As such, we need to add a task to install and set the correct Node.js version as default on the hosted agent, which is 12.9.1:

 

- task: UseNode@1
  inputs:
    version: '12.9.1'

 

Install the Windows 10 1903 SDK

React Native for Windows projects are compiled using, as target SDK, the 1903 (build 18836) one. However, since this version is fairly new, it's included only in the windows-latest hosted agent and not in the vs2017-win2016 one we're using. As such, if we want to avoid compilation errors, we need to install the SDK first on the hosted agent. The easiest way to do it is to leverage Chocolatey, the popular package manager for Windows. Think of it like NuGet, but for Windows applications instead of development libraries. Among the many packages it offers, we can find also the Windows 10 1903 SDK. Chocolatey is already installed on every Windows hosted agent, so you just need to add the following task:

 

- script: choco install windows-sdk-10-version-1903-all

 

Install the modules used by our React Native application

By default, the dependencies of a React Native application are not committed inside the repository, but they are restored the first time you build the application. This is a standard approach. This isn't code we have written, so it wouldn't make sense to increase the size of our repository for files that can be easily downloaded from Internet. We see the same, for example, with NuGet packages leveraged by .NET applications. As such, before building our project, we need to make sure that all the modules are downloaded and installed on the hosted agent. To achieve this goal we can use Yarn, which is installed as well on every hosted agent. As such, we just need to add the following task:

 

- script: yarn install

 

Install the React Native CLI

At some point, during the creation of the MSIX package, Visual Studio will launch the react-native bundle command, which takes care of bundling all the JavaScript files in a binary file, so that the application can run without the Metro packager. The react-native command is part of the React Native CLI, which isn't installed by default on the hosted agent. We need to install it first as a global tool, using NPM. However, there's a catch. When you install a package as global with NPM, it's installed only for the current user. The hosted agent, instead, performs all the tasks using a service which runs using a dedicated account, called VssAdministrator. As such, we need to install the React Native CLI for this user, otherwise the Visual Studio build will fail because it won't find it.

NPM supports setting the folder where to install global packages, by using the config parameter. Here are the tasks we need to launch:

 

- script: npm config set prefix C:\Users\VssAdministrator\AppData\Roaming\npm
- script: npm install -g react-native-cli

The first script sets, as installation folder for NPM packages, the AppData folder which belongs to the VssAdministrator user. The second script, instead, installs the React Native CLI in that folder.

 

Restore the NuGet packages

Before moving on we need to restore the NuGet packages. Many of the React Native for Windows projects, in fact, have dependencies on NuGet packages which are required by the whole solution to build.

 

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

As you can notice, also in this case we specify that we want to restore only the NuGet packages referenced by the main solution, which is stored inside the windows folder.

 

Build the Visual Studio solution

Now we can finally build the Visual Studio solution. Here we don't have to make too many changes to the default settings. This is the task I'm using:

 

- 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)'

In my case, I opted to generate a MSIX package and not a bundle (/p:AppxBundle=Never) and to use it for sideloading (/p:UapAppxPackageBuildMode=SideloadOnly). If you want to generate a bundle (which is suggested if you want to support multiple CPU architectures or you have lot of graphical assets), just set the /p:AppBundle parameter to Always. And if you want to publish your application on the Microsoft Store, just leave the /p:UapAppxPackageBuildMode parameter set to StoreUpload. The only parameter which I strongly encourage to add is /p:AppxPackageSigningEnabled=false, which will disable package signing during the build process. If you want to publish your application on the Microsoft Store, you don't need to digitally sign the package since the Store will do it for you. If, instead, you want to release it in other ways, you have to sign it but doing it during the build process performed by Visual Studio isn't considered a best practice. You would need, in fact, to upload the certificate on your repository, leaving you vulnerable to identity theft.

 

The deployment

Congratulations! Now, every time you'll commit new code to the repository, a build will be triggered and the hosted agent will create a new MSIX package with the latest version. That's the Continuous Integration part of our DevOps story. What about the Continuous Deployment? Once we have a MSIX package, we need to deploy it so that our users can get the most up-to-date version. We have different options: we can publish the package on the Microsoft Store; or we can leverage a technology called App Installer to deploy the package on a website and enable automatic updates from there.

To achieve this goal you're going to build a release pipeline, which will allow you to deploy your application in multiple stages. Azure DevOps offer many built-in tasks which makes the deployment easier: you have tasks to connect to the Microsoft Store; tasks to digitally sign the package with a certificate; tasks to copy the package on an Azure Storage; etc.

I won't explain all the details in this article. You can find all the information about the various options you have and how to implement them in the last chapter of my recently released e-book, called MSIX Succinctly, which is available for free thanks to Syncfusion. Alternatively, this topic is covered also by Exercise 6 of the Windows applications modernization workshop that my team has built.

 

What's next?

In this post we have learned how to create a CI/CD pipeline for a React Native for Windows project. But there's a catch. Let's say you have a project which includes some custom native modules you have built, following the approach described in my previous post.

If you setup a pipeline with the guidance described in this article, you'll start to hit a series of errors like the following ones during the Visual Studio build task:

[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 Microsoft.ReactNative.SharedManaged project, which contains the implementation of the various classes and attributes which make easier to turn a class into a native module for React Native, leverages many features of the C# language that has been added after the 7.0 release. Many of these features require Visual Studio 2019, while our hosted agent is running Visual Studio 2017.

Unfortunately, as we have learned in the beginning, due to the requirement of supporting the v141 C++ platform toolset we can't just switch our pipeline to use the windows-latest hosted agent. As such, we need to build a self-hosted agent with all our requirements.

 

But that's food for the next blog post =) In the meantime, you can review the final version of the pipeline we have built in a sample React Native project I put together on GitHub. The repository contains a file called azure-pipelines.yml, which contains the full YAML file.

 

Happy coding!