I've been attempting to create a YAML pipeline in Azure DevOps (Version Dev17.M153.3).
I created a simple Hello World C# console app and checked it into our locally hosted Azure-Git repo. I created my azure-pipelines.yml file and have tried various combinations of things in it including:
The ".NET Desktop" configuration
The "Starter Pipeline" configuration
A file from another C# project that I know works
A file form another project, with various mods to match my test project
A completely commented-out file
A completely blank file
However, every time I try to do a build, I get the following failure message:
/azure-pipelines.yml (Line: 1, Col: 1): A sequence was not expected
Given the error always occurs on line 1 and I've tried lots of different content in the file, I think something else must be configured incorrectly, rather than a problem with the YAML.
Does anyone have any ideas what I'm doing wrong, please?
Various Google searches find pages with similar errors, but none of the solutions helped me.
*** Edited to add various YAML file attempts:
I currently have a completely empty YAML file, but still get the error.
Previous files have included:
- task: DotNetCoreCLI#2
inputs:
command: 'build'
projects: '.'
---------------------------------
variables:
solution: 'HelloWorldCsharpSandpit.sln'
- task: VSBuild#1
displayName: 'Build solution (debug)'
inputs:
solution: '$(solution)'
vsVersion: 16.0
platform: x86
configuration: Debug
clean: true
timeoutInMinutes: 10
---------------------------------
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# [Link removed to avoid odd formatting.]
trigger:
- master
pool:
name: 'Default'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#0
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
---------------------------------
# .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:
# name: 'Default'
#
#variables:
# solution: '**/*.sln'
# buildPlatform: 'Any CPU'
# buildConfiguration: 'Release'
#
#steps:
#- task: NuGetToolInstaller#0
#
#- task: NuGetCommand#2
# inputs:
# restoreSolution: '$(solution)'
#
#- task: VSBuild#1
# inputs:
# solution: '$(solution)'
# platform: '$(buildPlatform)'
# configuration: '$(buildConfiguration)'
#
#- task: VSTest#2
# inputs:
# platform: '$(buildPlatform)'
# configuration: '$(buildConfiguration)'
---------------------------------
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
You have here mixed few pipelines.
Here is one:
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# [Link removed to avoid odd formatting.]
trigger:
- master
pool:
name: 'Default'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#0
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSBuild#1
displayName: 'Build solution (debug)'
inputs:
solution: '$(solution)'
vsVersion: 16.0
platform: x86
configuration: Debug
clean: true
timeoutInMinutes: 10
Here another but commented:
---------------------------------
# .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:
# name: 'Default'
#
#variables:
# solution: '**/*.sln'
# buildPlatform: 'Any CPU'
# buildConfiguration: 'Release'
#
#steps:
#- task: NuGetToolInstaller#0
#
#- task: NuGetCommand#2
# inputs:
# restoreSolution: '$(solution)'
#
#- task: VSBuild#1
# inputs:
# solution: '$(solution)'
# platform: '$(buildPlatform)'
# configuration: '$(buildConfiguration)'
#
#- task: VSTest#2
# inputs:
# platform: '$(buildPlatform)'
# configuration: '$(buildConfiguration)'
And once more:
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
If you modify you pipeline on the portal you can validate using this button:
Then you will get feedback if all is fine with your pipeline.
If you still have this issue
delete your pipeline from portal
delete your file from repo
start with template from portal
run it
adjust it to your need on portal and validate before saving changes
Related
I'm trying to deploy a c# MVC app to windows server running IIS where I have deployed another app as default site but this app which I want to build and deploy is only to a specific virtual folder
so for build steps I have used below steps :
paths:
exclude:
- gitignore
pool:
name: 'Hosted Windows 2019 with VS2019'
variables:
SolutionPath: '**/*.sln'
buildConfiguration: 'Release'
buildPlatform: 'Any CPU'
stages:
- stage: Build
displayName: Build app
jobs:
- job: Build
workspace:
clean: all
displayName: Build app
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(SolutionPath)'
- task: VSBuild#1
displayName: 'Build solution'
inputs:
solution: '$(SolutionPath)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:PackageAsSingleFile=false /p:SkipInvalidConfigurations=true /p:PackageLocation="$(Build.stagingdirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: $(Build.artifactstagingdirectory)
ArtifactName: 'drop' ```
As you can see I have set the msbuildArgs specially /p:WebPublishMethod=FileSystem to drop the files under virtual specific path.
as a outcome the build artifacts are coming out as a long path,not sure if I am missing something in terms of setting any argument for path to publish-
\drop\Archive\Content\D_C\a\1\s\temp\obj\Release\Package\PackageTmp\<app files>
Now in release pipeline I have used below IIS web app deploy task
[![Release pipeline][1]][1]
[1]: https://i.stack.imgur.com/Dkp7m.png
can someone explain me how do I should build it a specific virtual path so I can deploy it without interfering the default site
I'm trying to execute Playwright dotnet tests with Nunit framework on Azure DevOps. I'm unable to execute testcases as and when I try to install playwright as a part of pipeline, there is an error thrown and build gets failed with the following message
Couldn't find project using Playwright. Ensure a project or a solution
exists in D:\a\1\s, or provide another path using -p.
Below is my azure pipeline steps, Can someone please help me where exactly the issue is and I have tried both Windows and latest Ubuntu agents
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: UseDotNet#2
displayName: 'Install .NET'
inputs:
packageType: 'sdk'
version: '6.0.x'
installationPath: $(Agent.ToolsDirectory)/dotnet
includePreviewVersions: true
- task: DotNetCoreCLI#2
inputs:
command: 'build'
projects: '**/*.csproj'
- task: DotNetCoreCLI#2
inputs:
command: 'custom'
custom: 'new'
arguments: 'tool-manifest'
- task: DotNetCoreCLI#2
displayName: 'Installing Playwright Cli'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install Microsoft.Playwright.CLI'
- task: DotNetCoreCLI#2
displayName: 'Building tests project'
inputs:
command: 'build'
projects: '**/*Tests*.csproj'
- task: DotNetCoreCLI#2
displayName: Run Playwright Install
inputs:
command: custom
custom: 'tool '
arguments: run playwright install
- task: DotNetCoreCLI#2
displayName: 'Run tests'
inputs:
command: 'test'
projects: '**/*Tests*.csproj'
testRunTitle: 'new pipeline'
With Visual Studio projects you can add post-build-events, which will run on you dev machine and in the Azure Pipeline during a build (tested with VSBuild#1)
Example using the VS UI:
(you will need to adjust paths for ubuntu)
echo $(TargetDir).playwright\node\win32_x64\playwright.cmd install
$(TargetDir).playwright\node\win32_x64\playwright.cmd install
echo Done
or adding directly to a .csproj
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="echo $(TargetDir).playwright\node\win32_x64\playwright.cmd install;$(TargetDir).playwright\node\win32_x64\playwright.cmd install;echo Done" />
</Target>
I was trying to create a release pipeline in Azure DevOps.
All part works fine but getting error in IIS Web Deploy.
More than one package matched with specified pattern: %s. Please restrain the search pattern.
Here is the task for Web Deploy.
I have the yml as:
trigger:
- main
pool:
vmImage: 'windows-latest'
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: 'publish'
publishWebProjects: true
zipAfterPublish: true
arguments: '--output $(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts#1
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: AspNetCoreExample
More than one package matched with specified pattern: %s. Please restrain the search pattern
The zip files are came from your build pipeline. if you need only the .zip so configure your build pipeline publish artifacts task to take only this.
However, you have publish your project by the task VSBuild and DotNetCoreCLI:publish. In this case, you will have one more .zip file in your artifact, which will cause that issue.
- 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 #Move this task.
inputs:
command: 'publish'
publishWebProjects: true
zipAfterPublish: true
arguments: '--output $(build.artifactstagingdirectory)'
To resolve this issue, please move the task - task: DotNetCoreCLI#2 and make sure you have only one package in your .zip file.
I have multiple projects contained in my repo that I would like to build individual zip artifact to deploy them each separately. Currently, the pipeline builds one zip artifact that contains all the projects. How do I configure my azure-pipelines.yml file to accomplish this task? Below is my current file.
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: VSBuild#1
inputs:
solution: '$(solution)'
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: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
It depends on how you define the MSBuild arguments. The /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site" is the direct cause of the issue, it calls msbuild to package all projects into one WebApp.zip file.
With msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"' you can have separate ProjectName.zip files under $(build.artifactStagingDirectory) path.
And then you can use one Publish Build Artifact task to publish whole $(build.artifactStagingDirectory) directory which contains ProjectA.zip, ProjectB.zip...
Also you can use several Publish Build Artifact tasks in one pipeline for your several output xx.zip files.
You can change the build parameter /p:PackageAsSingleFile=false which will prevent all the projects from being zipped together. If you want to move the built files after the build, before the Publish Artifacts step, you can create a Copy files task that will copy the project's build folder to another location within the
'$(Build.ArtifactStagingDirectory)'
steps:
task: CopyFiles#2
displayName: 'Copy Project Files'
inputs:
SourceFolder: '$\ProjectName\bin$(BuildConfiguration)'
Contents: '****'
TargetFolder: '$(build.artifactstagingdirectory)\ProjectName'
CleanTargetFolder: true
Though these will all still be placed within the 'drop' folder or whatever the $(build.artifactstagingdirectory) is called. The only way to separate artifacts is to create separate pipelines for each project.
I have an azure pipeline that builds my asp.net core 2.2 project. I upgraded the project use c# 8.0. However, my azure pipelines don't seem to support c# 8.0. How do I upgrade my azure pipeline to use c# 8.0?
I have looked through the options in the azure pipeline and have not found anything on upgrading to c# 8.0
Here is the generated YAML file
pool:
name: Hosted VS2017
demands:
- msbuild
- visualstudio
steps:
- task: NuGetToolInstaller#0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
vstsFeed: '3e219c03-bc0d-4106-82be-9ff3b21190a5'
- task: VSBuild#1
displayName: 'Build solution'
inputs:
solution: '$(Parameters.solution)'
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: VSTest#2
displayName: 'Test Assemblies'
inputs:
testAssemblyVer2: |
**\$(BuildConfiguration)\*test*.dll
!**\obj\**
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
diagnosticsEnabled: True
enabled: false
- task: PublishSymbols#2
displayName: 'Publish symbols path'
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
continueOnError: true
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: '$(Parameters.ArtifactName)'
condition: succeededOrFailed()
I expect the project to build, but it gives me this error:
CSC : error CS1617: Invalid option '8.0' for /langversion. Use '/langversion:?' to list supported values.
I figured out the issue. Based on the YAML file, I am using the "Hosted 2017" agent pool. After I changed this to "Azure Pipelines" with the "windows-2019" specification, it worked.