diff --git a/builds/azure-pipelines.yml b/builds/azure-pipelines.yml index d117f2d60c12..9a7ee821596a 100644 --- a/builds/azure-pipelines.yml +++ b/builds/azure-pipelines.yml @@ -1,122 +1,51 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT license. See the LICENSE. + trigger: - main -pool: - vmImage: 'windows-latest' - -variables: - solution: '**/*.sln' - buildPlatform: 'x64' - buildConfiguration: 'Release' - appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\' - -steps: -- task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - [xml]$xmlDoc = Get-Content '$(Build.SourcesDirectory)\src\Files.App (Package)\Package.appxmanifest' - $xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP" - $xmlDoc.Package.Identity.Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" - $xmlDoc.Package.Properties.DisplayName="Files" - $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" - $xmlDoc.Save('$(Build.SourcesDirectory)\src\Files.App (Package)\Package.appxmanifest') - failOnStderr: true - -- task: PowerShell@2 - displayName: 'Use Release Logo' - inputs: - targetType: 'inline' - script: | - gci $(Build.SourcesDirectory)\src -Include *.csproj, *.appxmanifest, *.wapproj -recurse | ForEach -Process { - (Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\\AppTilesDev", "Assets\AppTiles"}) | Set-Content $_ -NoNewline - } - failOnStderr: true - -- task: DownloadSecureFile@1 - name: mapsDevKey - displayName: 'Download Bing Maps Dev Key' - inputs: - secureFile: 'BingMapsKey.txt' - -- task: CopyFiles@2 - inputs: - SourceFolder: '$(Agent.TempDirectory)' - Contents: '$(mapsDevKey.secureFilePath)' - TargetFolder: '$(Build.SourcesDirectory)\src\Files.App\Resources' - overWrite: true - -- task: UseDotNet@2 - inputs: - packageType: sdk - version: 7.0.x - includePreviewVersions: true - -- task: CmdLine@2 - inputs: - script: | - for /f %%a in ('dir /b /a:d %localappdata%\Microsoft\VisualStudio\17*') do echo UsePreviews=True>%localappdata%\Microsoft\VisualStudio\%%a\sdk.txt - -- task: MSBuild@1 - inputs: - platform: 'x64' - solution: '**/*.sln' - configuration: '$(buildConfiguration)' - msbuildArguments: '/t:restore /p:Configuration=Debug;Platform="$(buildPlatform)";PublishReadyToRun=true' - maximumCpuCount: true - -- task: MSBuild@1 - inputs: - platform: 'x64' - solution: '**/*.wapproj' - configuration: '$(buildConfiguration)' - msbuildArguments: '/t:build;_GenerateAppxPackage /p:Configuration=Debug;Platform="$(buildPlatform)";AppxBundle=Always;AppxBundlePlatforms="$(buildPlatform)";AppxPackageDir="$(appxPackageDir)";AppxPackageSigningEnabled=true;UapAppxPackageBuildMode=SideloadOnly;PackageCertificateKeyFile="$(Build.SourcesDirectory)\builds\Files_SelfSigned.pfx";PackageCertificatePassword="";PackageCertificateThumbprint=""' - maximumCpuCount: true - -- task: DotNetCoreCLI@2 - inputs: - command: 'build' - arguments: './tests/Files.InteractionTests/Files.InteractionTests.csproj --configuration $(buildConfiguration)' - -- task: PowerShell@2 - inputs: - targetType: 'inline' - script: | - # Find correct folder and run app install script. - cd $(appxPackageDir) - - $AppBundle = Get-ChildItem -Filter Files*Test -Name - echo $AppBundle - cd $AppBundle - ./Install.ps1 -Force - Get-AppxPackage - errorActionPreference: 'continue' - failOnStderr: true - workingDirectory: '$(System.DefaultWorkingDirectory)' - - -- task: Windows Application Driver@0 - inputs: - OperationType: 'Start' - AgentResolution: '1080p' - -- task: VSTest@2 - inputs: - testSelector: 'testAssemblies' - testAssemblyVer2: | - **\*Files.InteractionTests.dll - !**\*TestAdapter.dll - !**\obj\** - searchFolder: '$(System.DefaultWorkingDirectory)' - -- task: CopyFiles@2 - displayName: 'Copy Files to: $(build.artifactstagingdirectory)' - inputs: - SourceFolder: '$(system.defaultworkingdirectory)' - Contents: '**\bin\$(BuildConfiguration)\**' - TargetFolder: '$(build.artifactstagingdirectory)' - -- task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: drop' - inputs: - PathtoPublish: '$(build.artifactstagingdirectory)' +name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) + +stages: +- stage: Build + + pool: + vmImage: 'windows-latest' + + jobs: + - job: Platform + + timeoutInMinutes: 120 + strategy: + maxParallel: 10 + matrix: + Debug_x64: + buildPlatform: 'x64' + buildConfiguration: 'Debug' + Debug_Arm64: + buildPlatform: 'arm64' + buildConfiguration: 'Debug' + Release_x64: + buildPlatform: 'x64' + buildConfiguration: 'Release' + Release_x86: + buildPlatform: 'x86' + buildConfiguration: 'Release' + Release_Arm64: + buildPlatform: 'arm64' + buildConfiguration: 'Release' + + variables: + solutionPath: 'Files.sln' + packagingProjectPath: './tests/Files.App (Package)/Files.Package.wapproj' + interactionTestsProjectPath: './tests/Files.InteractionTests/Files.InteractionTests.csproj' + appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages' + + steps: + - template: templates/Files-BuildProjects-Steps.yml + +- stage: Test + dependsOn: Build + jobs: + + - template: templates\Files-RunInteractionTest-Steps.yml diff --git a/builds/templates/Files-BuildProjects-Steps.yml b/builds/templates/Files-BuildProjects-Steps.yml new file mode 100644 index 000000000000..2584fe039803 --- /dev/null +++ b/builds/templates/Files-BuildProjects-Steps.yml @@ -0,0 +1,33 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT license. See the LICENSE. + +steps: +- template: Files-UpdatePackage-Steps.yml + +- template: Files-InstallDotNetSDK-Steps.yml + +- template: Files-SetupBingMapSecrets-Steps.yml + +- template: Files-UseVS2022Preview-Steps.yml + +- template: Files-PrepareTheSolution.yml + +- task: MSBuild@1 + displayName: 'Build the package project' + inputs: + platform: '$(buildPlatform)' + solution: '**/*.wapproj' + configuration: '$(buildConfiguration)' + msbuildArguments: ' + /t:build;_GenerateAppxPackage + /p:Configuration="$(buildConfiguration)" + /p:Platform="$(buildPlatform)" + /p:AppxBundle=Always + /p:AppxBundlePlatforms="$(buildPlatform)" + /p:AppxPackageDir="$(appxPackageDir)" + /p:AppxPackageSigningEnabled=true + /p:UapAppxPackageBuildMode=SideloadOnly + /p:PackageCertificateKeyFile="$(Build.SourcesDirectory)\builds\Files_SelfSigned.pfx" + /p:PackageCertificatePassword="" + /p:PackageCertificateThumbprint=""' + maximumCpuCount: true diff --git a/builds/templates/Files-InstallDotNetSDK-Steps.yml b/builds/templates/Files-InstallDotNetSDK-Steps.yml new file mode 100644 index 000000000000..54e3f2d8f21c --- /dev/null +++ b/builds/templates/Files-InstallDotNetSDK-Steps.yml @@ -0,0 +1,10 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT license. See the LICENSE. + +steps: +- task: UseDotNet@2 + displayName: 'Install .NET' + inputs: + packageType: sdk + version: 7.0.x + includePreviewVersions: true diff --git a/builds/templates/Files-PrepareTheSolution.yml b/builds/templates/Files-PrepareTheSolution.yml new file mode 100644 index 000000000000..cce4c20eafe4 --- /dev/null +++ b/builds/templates/Files-PrepareTheSolution.yml @@ -0,0 +1,16 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT license. See the LICENSE. + +steps: +- task: MSBuild@1 + displayName: 'Restore the solution' + inputs: + platform: '$(buildPlatform)' + solution: '$(variables.solutionPath)' + configuration: '$(buildConfiguration)' + msbuildArguments: ' + /t:restore + /p:Configuration=$(buildConfiguration) + /p:Platform="$(buildPlatform)" + /p:PublishReadyToRun=true' + maximumCpuCount: true diff --git a/builds/templates/Files-PublishBuildArtifacts-Steps.yml b/builds/templates/Files-PublishBuildArtifacts-Steps.yml new file mode 100644 index 000000000000..945602c1b83c --- /dev/null +++ b/builds/templates/Files-PublishBuildArtifacts-Steps.yml @@ -0,0 +1,16 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT license. See the LICENSE. + +steps: +- task: CopyFiles@2 + displayName: 'Copy the artifacts' + inputs: + SourceFolder: '$(system.defaultworkingdirectory)' + Contents: '**\bin\$(BuildConfiguration)\**' + TargetFolder: '$(build.artifactstagingdirectory)' + +- task: PublishBuildArtifacts@1 + displayName: 'Publish the artifacts' + inputs: + ArtifactName: 'PackageArtifactsOfDevCondition' + PathtoPublish: '$(build.artifactstagingdirectory)' diff --git a/builds/templates/Files-RunInteractionTest-Steps.yml b/builds/templates/Files-RunInteractionTest-Steps.yml new file mode 100644 index 000000000000..9d77063010a2 --- /dev/null +++ b/builds/templates/Files-RunInteractionTest-Steps.yml @@ -0,0 +1,42 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT license. See the LICENSE. + +steps: +- task: DotNetCoreCLI@2 + inputs: + command: 'build' + arguments: '$(interactionTestsProjectPath) --configuration x64' + +- task: PowerShell@2 + inputs: + targetType: 'inline' + script: | + # Find correct folder and run app install script. + cd $(appxPackageDir) + + $AppBundle = Get-ChildItem -Filter Files*Test -Name + echo $AppBundle + cd $AppBundle + ./Install.ps1 -Force + Get-AppxPackage + errorActionPreference: 'continue' + failOnStderr: true + workingDirectory: '$(System.DefaultWorkingDirectory)' + +- task: Windows Application Driver@0 + inputs: + OperationType: 'Start' + AgentResolution: '1080p' + +- task: VSTest@2 + inputs: + testSelector: 'testAssemblies' + testAssemblyVer2: | + **\*Files.InteractionTests.dll + !**\*TestAdapter.dll + !**\obj\** + searchFolder: '$(System.DefaultWorkingDirectory)' + +- task: Windows Application Driver@0 + inputs: + OperationType: 'Stop' diff --git a/builds/templates/Files-SetupBingMapSecrets-Steps.yml b/builds/templates/Files-SetupBingMapSecrets-Steps.yml new file mode 100644 index 000000000000..8bb717e1c3ae --- /dev/null +++ b/builds/templates/Files-SetupBingMapSecrets-Steps.yml @@ -0,0 +1,17 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT license. See the LICENSE. + +steps: +- task: DownloadSecureFile@1 + displayName: 'Download BingMap dev key' + name: mapsDevKey + inputs: + secureFile: 'BingMapsKey.txt' + +- task: CopyFiles@2 + displayName: 'Copy BingMap dev key' + inputs: + SourceFolder: '$(Agent.TempDirectory)' + Contents: '$(mapsDevKey.secureFilePath)' + TargetFolder: '$(Build.SourcesDirectory)\src\Files.App\Resources' + overWrite: true diff --git a/builds/templates/Files-UpdatePackage-Steps.yml b/builds/templates/Files-UpdatePackage-Steps.yml new file mode 100644 index 000000000000..b2d6f4e174f0 --- /dev/null +++ b/builds/templates/Files-UpdatePackage-Steps.yml @@ -0,0 +1,25 @@ +# TODO: Move to scripts + +steps: +- task: PowerShell@2 + displayName: 'Set appropriate package info' + inputs: + targetType: 'inline' + script: | + [xml]$xmlDoc = Get-Content '$(Build.SourcesDirectory)\src\Files.App (Package)\Package.appxmanifest' + $xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP" + $xmlDoc.Package.Identity.Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" + $xmlDoc.Package.Properties.DisplayName="Files" + $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" + $xmlDoc.Save('$(Build.SourcesDirectory)\src\Files.App (Package)\Package.appxmanifest') + failOnStderr: true + +- task: PowerShell@2 + displayName: 'Set appropriate package logo' + inputs: + targetType: 'inline' + script: | + gci $(Build.SourcesDirectory)\src -Include *.csproj, *.appxmanifest, *.wapproj -recurse | ForEach -Process { + (Get-Content $_ -Raw | ForEach -Process {$_ -replace "Assets\\AppTilesDev", "Assets\AppTiles"}) | Set-Content $_ -NoNewline + } + failOnStderr: true \ No newline at end of file diff --git a/builds/templates/Files-UseVS2022Preview-Steps.yml b/builds/templates/Files-UseVS2022Preview-Steps.yml new file mode 100644 index 000000000000..11634d734299 --- /dev/null +++ b/builds/templates/Files-UseVS2022Preview-Steps.yml @@ -0,0 +1,9 @@ +# Copyright (c) 2023 Files Community +# Licensed under the MIT license. See the LICENSE. + +steps: +- task: CmdLine@2 + displayName: 'Use preview version of VS2022 SDK' + inputs: + script: | + for /f %%a in ('dir /b /a:d %localappdata%\Microsoft\VisualStudio\17*') do echo UsePreviews=True>%localappdata%\Microsoft\VisualStudio\%%a\sdk.txt diff --git a/scripts/Files-UpdatePackage-Script.ps1 b/scripts/Files-UpdatePackage-Script.ps1 new file mode 100644 index 000000000000..c7e0989f9454 --- /dev/null +++ b/scripts/Files-UpdatePackage-Script.ps1 @@ -0,0 +1,4 @@ +<# + + +#>