I'm trying to add a run task using the .Net Core task but after it shows that the app is up on a localhost, it can't move onto the next task. I believe it doesn't move onto the next task because the .Net task never ends. I want the task to run so that it is up on the localhost and then move onto the next task to test it. here's my pipeline
trigger:
- development
pool:
vmImage: 'windows-latest'
resources:
repositories:
- repository: e2ecypress
type: git
name: devopsapp/e2ecypress
jobs:
- job: build_unit_tests
displayName: '.Net Build & Unit Test'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI#2
inputs:
command: 'run'
projects: '*/*.csproj'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
I assume DotNetCoreCLI#2 just calls "dotnet run". If your program is a console program that "never ends", then I would indeed expect your pipeline to block there.
To start your program without blocking, I think that instead of using DotNetCoreCLI#2, you need to insert a "- script" that calls the Windows "start" command to directly call "dotnet run".
Related
I have an Azure Pipeline that builds a Winform solution with multiple projects that are Strong signed with a PFX.
I found the following link:
https://dhvik.blogspot.com/2020/01/building-strong-named-assemblies-in.html
This is my YAML file:
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
- group: 'CertPass'
steps:
- task: DownloadSecureFile#1
displayName: Download Pfx
name: myCertificatePfx
inputs:
secureFile: ventasmlcert.pfx
- task: DownloadSecureFile#1
displayName: Download sni
name: snInstallPfx
inputs:
secureFile: SnInstallPfx.exe
- task: PowerShell#2
env:
SN_INSTALL_PFX: $(snInstallPfx.secureFilePath)
MYCERTIFICATE_PFX: $(myCertificatePfx.secureFilePath)
MYCERTIFICATE_PFX_PASSWORD: $(certpass)
inputs:
targetType: 'inline'
script: '&"$($ENV:SN_INSTALL_PFX)" "$($ENV:MYCERTIFICATE_PFX)" "$($ENV:MYCERTIFICATE_PFX_PASSWORD)"'
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
displayName: 'Build .csproj file'
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
Everything works fine in the pipeline for the signing of my PFX:
But when building the solution I still get the error, but was looking that the Container where the signing was added is different from the other Containers of each project that needs to be signed.
This is the error:
Error MSB3325: Cannot import the following key file: ***cert.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_71452E506F1E61FB
Any clue?
I'm trying to setup a release pipeline in azure devops which is supposed to deploy my web site to virtual machine, that is, update an existing web site already running on IIS.
I'm getting the following errors:
2021-02-25T20:47:55.4825268Z ##[error]Failed to deploy web package to IIS website.
2021-02-25T20:47:55.4836851Z ##[error]Error: The account 'RISK\PANDA' does not appear to be valid. The account was obtained from this location: 'system.applicationHost/applicationPools/DataConverterAPI'.
Error: Some or all identity references could not be translated.
Error count: 1.
2021-02-25T20:47:55.4839506Z ##[error]Error: The process 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe' failed with exit code 4294967295
here's my build pipeline .yml file content:
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
userPassword: 'myPass'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
IIS Web App Manage task .yml:
steps:
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'IIS Web App Manage'
inputs:
WebsiteName: DataConverterAPI
WebsitePhysicalPath: '%SystemDrive%\DataConverterAPI'
AddBinding: True
Bindings: '{"bindings":[{"protocol":"http","ipAddress":"All Unassigned","port":"50352","hostname":"","sslThumbprint":"","sniFlag":false}]}'
BasicAuthenticationForWebsite: true
WindowsAuthenticationForWebsite: false
ParentWebsiteNameForVD: DataConverterAPI
ParentWebsiteNameForApplication: DataConverterAPI
IIS Web App Deploy task .yml:
steps:
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: DataConverterAPI
TakeAppOfflineFlag: True
XmlVariableSubstitution: True
someone help pls.
alright I fixed this by changing the pool identity on which my application run to 'ApplicationPoolIdentity'
and sadly I don't know yet why it solved the problem, any comments would be appreciated
I am using Azure Devops YAML build pipeline for the build and test of my SQL SSDT project. I am trying to amend my YAML code so that the test part will run on multiple Microsoft hosted agents (I have purchased 2). When I run the VSTest task as part of the first job that is run on the single agent, it runs no problems. However, when I run it as part of the second job, the unit tests do not run, with an error saying it cannot find the requisite test files. Is there something I need to add to my second job to make this work?
Many thanks.
trigger:
branches:
include:
- develop
- stage
- master
pr:
- master
- stage
- develop
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
jobs:
- job: BuildPublish
steps:
- task: NuGetToolInstaller#1
inputs:
versionSpec: '2.*'
- task: NuGetCommand#2
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'select'
restoreDirectory: '$(Build.SourcesDirectory)/DIP_UsqlSln/packages'
- task: VSBuild#1
inputs:
solution: '**/*.sln'
msbuildArgs: '/p:USQLSDKPath=$(Build.SourcesDirectory)/DIP_UsqlSln/packages/Microsoft.Azure.DataLake.USQL.SDK.1.4.190703/build/runtime;USQLTargetType=SyntaxCheck;DataRoot=$(Build.SourcesDirectory) /p:EnableDeployment=true'## Heading ##
createLogFile: true
logFileVerbosity: 'detailed'
- task: CopyFiles#2
inputs:
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)'
CleanTargetFolder: true
OverWrite: true
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- job: Test
dependsOn: BuildPublish
strategy:
parallel: 2
steps:
- task: DownloadBuildArtifacts#0
displayName: 'Download Build Artifacts'
inputs:
artifactName: 'drop'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
runOnlyImpactedTests: true
runInParallel: true
How to find unit test dll in Azure Devops when copying test artifact to run on multiple agents (YAML)
That because the default Destination directory for the task DownloadBuildArtifacts is $(System.ArtifactsDirectory), however, the default Search folder for Visual Studio Test task is $(System.DefaultWorkingDirectory).
When you use the those two task in the build pipeline, the value of those two predefined variables are not same:
The value of $(System.ArtifactsDirectory) should be C:\agent\_work\r1\a.
The value of $(System.DefaultWorkingDirectory) should be c:\agent_work\1\s.
So, it will cause this issue, could not found the requisite test files.
To resolve this issue, we just need to change the default value of those two predefined variables to use same value:
- task: DownloadBuildArtifacts#0
displayName: 'Download Build Artifacts'
inputs:
artifactName: drop
downloadPath: '$(System.DefaultWorkingDirectory)'
Or
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
searchFolder: '$(System.ArtifactsDirectory)'
runOnlyImpactedTests: true
runInParallel: true
Hope this helps.
I am using Azure DevOps to Build and deploy my Azure Synapse
I have two YAML files. First one works well and I need to separate Build and Release steps. because of that I wrote second YAML file. Second YAML file has this error :
##[error]No files were found to deploy with search pattern
d:\a\1\s\SQL_ASynapse\bin\Release\SQL_ASynapse.dacpacCheck out how to troubleshoot failures at
https://aka.ms/sqlazuredeployreadme#troubleshooting-
First YAML file that works well:
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: AzureKeyVault#1
inputs:
azureSubscription: 'XXX'
KeyVaultName: 'XXX-Dev'
SecretsFilter: '*'
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: SqlAzureDataWarehouseDacpacDeployment#1
inputs:
azureSubscription: 'XXX'
AuthenticationType: 'server'
ServerName: 'XXX'
DataWarehouse: '$(SynapseName)'
SqlUsername: '$(SynapseSQLUsername)'
SqlPassword: '$(SynapseSQLPassword)'
deployType: 'DacpacTask'
DeploymentAction: 'Publish'
DacpacFile: 'SQL_ASynapse\bin\Release\SQL_ASynapse.dacpac'
IpDetectionMethod: 'AutoDetect'
Second YAML file who has error:
trigger:
- master
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
# Agent VM image name
vmImageName: 'windows-latest'
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: 'development'
pool:
vmImage: $(vmImageName)
strategy:
runOnce:
deploy:
steps:
- task: AzureKeyVault#1
inputs:
azureSubscription: 'XXX-Dev'
KeyVaultName: 'XXX-Dev'
SecretsFilter: '*'
- task: SqlAzureDataWarehouseDacpacDeployment#1
inputs:
azureSubscription: 'XXX-Dev'
AuthenticationType: 'server'
ServerName: 'XXX'
DataWarehouse: '$(SynapseName)'
SqlUsername: '$(SynapseSQLUsername)'
SqlPassword: '$(SynapseSQLPassword)'
deployType: 'DacpacTask'
DeploymentAction: 'Publish'
DacpacFile: 'SQL_ASynapse\bin\Release\SQL_ASynapse.dacpac'
IpDetectionMethod: 'AutoDetect'
UPDATE #1 FOR #Levi Lu-MSFT ANSWER
I have changed my second script like below code :
...
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- publish: $(system.defaultworkingdirectory)\SQL_ASynapse\bin\Release ## path to a file or folder
artifact: MyBuildOutputs
...
- download: current # refers to artifacts published by current pipeline
artifact: MyBuildOutputs
- task: SqlAzureDataWarehouseDacpacDeployment#1
inputs:
azureSubscription: 'xxx-Dev'
AuthenticationType: 'server'
ServerName: 'xxx.database.windows.net'
DataWarehouse: '$(SynapseName)'
SqlUsername: '$(SynapseSQLUsername)'
SqlPassword: '$(SynapseSQLPassword)'
deployType: 'DacpacTask'
DeploymentAction: 'Publish'
DacpacFile: 'SQL_ASynapse\bin\Release\SQL_ASynapse.dacpac'
IpDetectionMethod: 'AutoDetect'
But I have still same error.
Upload task result
Download task result
SqlAzureDataWarehouseDacpacDeployment error :
##[error]No files were found to deploy with search pattern
d:\a\1\s\SQL_ASynapse\bin\Release\SQL_ASynapse.dacpacCheck out how to
troubleshoot failures at https://aka.ms/sqlazuredeployreadme#troubleshooting-
If you use Microsoft-hosted agent. Every job defined in the yaml pipeline will run on a fresh new virtual machine. The virtual machine is discarded after one use.
So that the build artifacts from Build job of Build stage doesnot exist on the agent machine of the deploy job of Deploy stage. That's why you got above error.
You need to add a publish task after Vsbuild task in Build job to publish the build results to azure devops server. You should specify the correct path(where the build artifacts reside) to publish.
- publish: $(system.defaultworkingdirectory)\SQL_ASynapse\bin\Release ## path to a file or folder
artifact: MyBuildOutputs
Then add a download task before qlAzureDataWarehouseDacpacDeployment task in Deploy job to download the build results to deploy job agent. So that the build results will be available to the deployment tasks.
- download: current # refers to artifacts published by current pipeline
artifact: MyBuildOutputs
To publish and download build artifacts, You can also use Publish Build Artifacts task, Download Build Artifacts task.
Update:
When you use download task: See here for more information.
By default, files are downloaded to $(Pipeline.Workspace)/{artifact}, where artifact is the name of the artifact. The folder structure of the artifact is always preserved.
And you can see from above updated screenshot. The artifacts is downloaded to folder D:\a\1\MyBuildOutputs
So you should set DacpacFile attribute as below:
DacpacFile : $(Pipeline.Workspace)/MyBuildOutputs/SQL_ASynapse.dacpac
I have the following .yml configuration to run my automated tests.
pool:
name: Hosted VS2017
demands:
- msbuild
- visualstudio
- vstest
steps:
- script: set
displayName: print all variables
- task: NuGetToolInstaller#0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: '**\*.sln'
- task: VSBuild#1
displayName: 'Build solution'
inputs:
solution: '**\*.sln'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: PowerShell#2
displayName: 'Set Sauce Environment Variables'
inputs:
targetType: filePath
filePath: ./setEnvironmentVariables.ps1
arguments: '$env:sauce_userName sauce_accessKey $env:SAUCE_RDC_VODQANATIVEAPPAPIKEY $env:SAUCE_RDC_SauceDemoIosRdcApiKey'
- task: VSTest#2
displayName: 'Run Best Practices Framework'
inputs:
#testSelector: 'testAssemblies'
#testAssemblyVer2: '**/*Selenium3.Nunit.Framework*'
testFiltercriteria: 'TestCategory=BestPractices'
runInParallel: true
codeCoverageEnabled: true
testRunTitle: 'NUnit Automation Framework'
rerunFailedTests: true
rerunFailedThreshold: 10
rerunMaxAttempts: 2
failOnMinTestsNotRun: true
I notice that in the logs that the only executables that are being checked for tests are in this folder D:\a\1\s\SauceExamples\packages\ which isn't correct.
As a result, I keep getting the following message NUnit couldn't find any tests in D:\a\1\s\SauceExamples\packages\
How can I make the VSTest#2 actually look in the correct .dll for automated tests?
Locally, the path of that .dll looks like this:
C:\Source\SauceLabs\demo-csharp\SauceExamples\Web.Tests\bin\Debug\Selenium3.Nunit.Framework.dll
The test files format should look like testAssemblyVer2: '**\*test*.dll', so you may
try the following format:
testAssemblyVer2: '**\Selenium3.Nunit.Framework.dll'