I have Asp.net CI, which publishes .zip artifacts.
When I download the .zip artifact, I have to go through many folders to be able to see the files.
I used the default arguments when building solution and many other ones, but no result.
Is there a way to publish the .zip so, that when I download it I see the files already?
In .net core that issue doesn't occur, but in asp.net does.
I used templated not yaml files.
Soulution build:
steps:
- task: VSBuild#1
displayName: 'Build solution'
inputs:
solution: '$(Parameters.solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
Publish Symbols
steps:
- task: PublishSymbols#2
displayName: 'Publish symbols path'
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
continueOnError: true
Publish artifact
steps:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact WEB: to drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)\HRSoft.WebClient.zip'
ArtifactName: '$(Parameters.ArtifactName)'
condition: succeededOrFailed()
In your msbuildArgs you should say that you want the artifacts as zip:
/p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" or /p:p:PackageLocation="$(build.artifactstagingdirectory)\WebApp.zip"
Related
I'm trying to publish a couple of pipeline artifacts during a build so that I can use them in a build of another solution.
My first build builds and tests the soltuion using the following yaml
- stage: build_test_release
displayName: Build
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
jobs:
- job: build
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: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
This all works great and I've been able to do deployments using this yaml in the same file
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'azuresubscription'
appType: 'webApp'
WebAppName: 'webappname'
deployToSlotOrASE: true
ResourceGroupName: 'resourcegroupname'
SlotName: 'staging'
packageForLinux: '$(build.artifactStagingDirectory)/**/projectToPublish.zip'
I'm now trying to publish some of the projects which were build as Pipeline Artifacts so that I can use them in the build of another solution which references them. The following publish task gives me the error:
"##[error]Path does not exist: D:\a\1\a**\projectToPublish.zip"
- task: PublishPipelineArtifact#1
inputs:
targetPath: '$(build.artifactStagingDirectory)/**/projectToPublish.zip'
artifact: 'artifactname'
publishLocation: 'pipeline'
What am I missing here? I've been thinking of moving the projects which are referenced by both soltuions into their own solutions and adding them as nuget packages or something similar. The projects I am trying to publish as artifacts to be used in the second solution are both WCF Client projects.
Thanks!
The issue is that the task you're using, Publish Pipeline Artifacts, does not support wildcards for the 'File or directory path' argument. For this task $(build.artifactStagingDirectory) is replaced with D:\a\1\a\, in the second directory named a Azure DevOps is looking for a sub directory named ** which does not exist and causes the shown error. The other task AzureRmWebAppDeployment#4 you're using does support wildcards.
See the image below, where Azure DevOps shows in the the UI that the PublishPipelineArtifact#1 task does not support wildcards in targetPath:
Second I'm wondering why you're using a wildcard, because the task VSBuild#1 will just drop the package in the build.artifactStagingDirectory which should make the path $(build.artifactStagingDirectory)/projectToPublish.zip to locate the package.
In AzureRmWebAppDeployment#4 you have
'$(build.artifactStagingDirectory)/**/WebProjectToPublish.zip'
And in PublishPipelineArtifact#1 you have a different name
'$(build.artifactStagingDirectory)/**/projectToPublish.zip'
I notice that files such as EntityFramework.Dll are deployed with the current time.
I have been experiencing this error and I resolved it by copying dlls from my development machine to the overwrite deployed dlls.
What causes the date to change on the dlls?
azure-pipelines.yml is
trigger:
- master
pool:
vmImage: 'VS2017-Win2016'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- task: NuGetToolInstaller#0
- task: NuGetCommand#2
inputs:
restoreSolution: '**\*.sln'
feedsToUse: config
nugetConfigPath: 'MyService.ServiceHost/nuget.config'
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles#2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
$(Build.SourcesDirectory)\MyService.ServiceHost\bin\debug\**\*.*
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts#1
inputs:
artifactName: 'drop'
my nuget.config references
and a private feed in https://pkgs.dev.azure.com
[Update]
I tried adding preserveTimestamp: True to the CopyFiles#2 task but it made no difference
- task: CopyFiles#2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: |
$(Build.SourcesDirectory)\MyService.ServiceHost\bin\debug\**\*.*
TargetFolder: '$(build.artifactstagingdirectory)'
preserveTimestamp: True
[Update]
Leo advises a work around.
However I am wondering how to unzip the file to release
Currently my release pipeline contains
copy C:\azagent\A2\_work\r1\a\_PreMyFolder\drop\MyService.ServiceHost\bin\Debug\*.* "C:\Program Files (x86)\MyCompany\MyService Service"
Why does Azure Devops change the date on dlls downloaded from Nuget?
That because the default value of the preserveTimestamp option is False in the Copy Files task.
- task: CopyFiles#2
inputs:
#sourceFolder: # Optional
#contents: '**'
targetFolder:
#preserveTimestamp: false # Optional
To resolve this issue, you just need change the value to True.
- task: CopyFiles#2
inputs:
sourceFolder:
contents: '**'
targetFolder:
preserveTimestamp: True
Update:
I tried adding preserveTimestamp: True to the CopyFiles#2 task but it
made no difference
When I first tested this issue, I found that the copy task would modify the Timestamp of the file. This is indeed the case. And found a solution using option preserveTimestamp. I thought this was the whole issue until Kirsten Greed replied to me that this solution did not work.
I had to test the issue again and found that the PublishBuildArtifacts task would also modify the Timestamp of the file, but there is no such preserveTimestamp option like copy task. We could found some similar thread here and here, but none of them gives a solution/workaround.
The workaround I currently think of is that you could try to Bundle the artifacts in a compressed zip file, then unzip it when you use it.
So, I use the Archive files instead of the copy task:
- task: ArchiveFiles#2
displayName: 'Archive $(Build.SourcesDirectory)\TestSample\TestSample\bin\Debug'
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)\TestSample\TestSample\bin\Debug'
archiveFile: '$(Build.ArtifactStagingDirectory)/Test.zip'
Then publish this zip file as artifact:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
Now, I could keep the Timestamp for the files:
Hope this helps.
I have this same problem. If I zip the files or simply do a Machine File Copy task to the server the date modified is always updated by Azure Dev Ops.
I don't believe is it currently possible to deploy from Dev Ops whilst preserving the date modified of the files.
I am new to DevOps and CICD pipelines.
I successfully deployed ASP .NET MVC website using Azure DevOps CICD pipeline to my onprem agent/machine using Azure DevOps.
Similarly I want to deploy a console application which can be
ultimately used as scheduled job in windows 'Task Scheduler' or either
as a 'Windows Service'. Right now I am managing these deployments
manually but after seeing the power of DevOps I hope, there could be
really some automated solution for console apps as well.
The applications are built in legacy framework like 3.5 to 4.5, so not .net core apps.
I found lot of online articles which demonstrates deploying webjobs on azure or may be possible for onprem but is it possible for old console apps?
I tried to build a very simple console app in Framework 4.7 and tried to deploy/copy/publish to my onprem machine's shared path. Gave permission to VSTS agent services which are running but copy files and publish artifact tasks are failing. I tried to do it in both CI and CD pipelines but all are failing.
Please review the pipelines and logs and suggest where I am doing wrong or there are any alternatives?
https://dev.azure.com/MSTCsandippatel/DemoConsoleApp
2019-11-05T05:03:52.8436105Z ##[error]Publishing build artifacts
failed with an error: Unable to create directory '\MAHANTAM\Azure
Artifacts\DemoConsoleApp'. Unable to verify the directory exists:
'\MAHANTAM\Azure Artifacts\DemoConsoleApp'. If directory is a file
share, please verify the share name is correct, the share is online,
and the current process has permission to access the share.
CI pipeline 1
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:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'DemoConsoleApp'
publishLocation: 'Container'
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:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'DemoConsoleApp'
publishLocation: 'Container'
CI pipeline 2
pool:
name: Azure Pipelines
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: '622d44e2-69d4-4d42-bb91-9d6ddd97f9ba/8eaf9077-829d-4567-93c0-8e0d7973634b'
- task: VSBuild#1
displayName: 'Build solution **\*.sln'
inputs:
solution: '$(Parameters.solution)'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: PublishSymbols#2
displayName: 'Publish symbols path'
inputs:
SearchPattern: '**\bin\**\*.pdb'
PublishSymbols: false
continueOnError: true
- task: CopyFiles#2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(system.defaultworkingdirectory)'
Contents: '**\bin\$(BuildConfiguration)\**'
TargetFolder: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
- task: CopyFiles#2
displayName: 'Copy Files Task'
inputs:
SourceFolder: '$(system.defaultworkingdirectory)'
Contents: '**/**'
TargetFolder: '$(build.artifactstagingdirectory)'
condition: succeededOrFailed()
- task: ArchiveFiles#2
displayName: 'Archive $(Build.BinariesDirectory)'
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: DemoConsoleApp'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: DemoConsoleApp
If you use Agent Pool "Azure Pipelines" for your agent, the deployment will occur on an azure cloud machine which doesn't know anything about your on-premise machines.
You should install a self-hosted agent on-premise and link that to your DevOps and use that for the agent.
https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops
I'm developing a Windows WPF application that I have set up a build pipeline for in Azure Devops. My problem is that I can't seem to figure out any way to download the artifacts after successfully completing the build.
Is it possible to get a link to a zip containing all the built files somehow. How can I get my files? I don't want to publish to NPM or NuGet or anything like that, just download to my desktop for now.
Thanks!
Edit: This is my build configuration
trigger:
- master
pr:
- master
pool:
vmImage: 'VS2017-Win2016'
variables:
solution: '**/*.sln'
buildPlatform: 'x64'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#0
displayName: 'NuGet Tool Installer'
- task: NuGetCommand#2
displayName: 'Restore NuGet dependencies'
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
displayName: 'Build $(buildConfiguration) $(buildPlatform)'
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: CopyFiles#2
displayName: 'Copy files'
inputs:
Contents: '_buildOutput\\**\\*.dll'
TargetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts#1
displayName: 'Publishing artifact drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
publishLocation: 'filePath'
targetPath: '$(Build.ArtifactStagingDirectory)\\outdir\\$(Build.DefinitionName)\\$(Build.BuildNumber)'
- task: DownloadBuildArtifacts#0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'drop'
downloadPath: '$(System.ArtifactsDirectory)'
You may use 2 ways:
Copy the download link from the build results:
Use link from this example (Artifacts - Get Artifact).
You need to know the Id for your build.
Then you may use download link with this format (for drop by default):
https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName=drop&api-version=5.0&%24format=zip
Updates (if you use yaml):
You have to use the "Publish Artifact" task if you want to work with build result and have the "Artifact" button.
You can publish it to Azure DevOps (by default):
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: 'Your folder with build results'
Also you can publish you results to the some file share:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: 'Your folder with build results'
publishLocation: FilePath
TargetPath: '\\my\share\$(Build.DefinitionName)\$(Build.BuildNumber)'
Updates 2:
If try to download your with format:
https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName=drop&api-version=5.0
You will get json with urls:
You may add "&%24format=zip" to the end of url and get a zip file:
Update 3
This is the part of my yaml build definition that was converted from standard build:
- task: CopyFiles#2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(build.sourcesdirectory)'
Contents: '**\bin\$(buildConfiguration)\**'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
I am planning to run end to end tests overnight using VSTS. Is there any guiding document or sample plans to show how to implement this.
Basically we have API projects in VSTS where we have End to End test projects within the main solution. So we wanted to run those tests overnight. All the other tests run as part of the build but NOT E2E as it should run after the deployment.
This is the build.yaml
resources:
- repo: self
queue:
name: Hosted VS2017
demands:
- vstest
- msbuild
- visualstudio
variables:
BuildPlatform: 'any cpu'
BuildConfiguration: 'release'
steps:
- task: NuGetToolInstaller#0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand#2
displayName: 'NuGet restore'
- task: VSBuild#1
displayName: 'Build solution'
inputs:
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(Build.ArtifactStagingDirectory)\app.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: powershell#2
inputs:
targetType: filePath
filePath: deploy/lib/GetSwaggerByExe.ps1
arguments: '-RootDirectory "src/SwaggerGenerator" -OutputFile "deploy/swagger/swagger.json" '
displayName: 'Create Swagger file'
- task: VSTest#2
displayName: 'Test Assemblies'
inputs:
testAssemblyVer2: |
**\$(BuildConfiguration)\*test*.dll
!**\obj\**
!**\*\*.EndToEnd.Integration.Tests*.dll
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: PublishTestResults#2
displayName: 'Publish API Test Results'
inputs:
testResultsFormat: VSTest
testResultsFiles: '**/*.trx'
- task: PublishSymbols#2
displayName: 'Publish symbols path'
inputs:
PublishSymbols: false
continueOnError: true
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/app.zip'
ArtifactName: app
- task: PublishBuildArtifacts#1
displayName: 'Publish deploy scripts'
inputs:
PathtoPublish: deploy
ArtifactName: deploy
I have below task in CD
Is this because of the incorrect path in test files parameter in the above task step. If so how to find out the correct path? I have referred below links as well, no luck though.
Build logs
Project "D:\a\1\s\src\XXXXSearch.Api.sln" (1) is building "D:\a\1\s\src\XXXSearch.EndToEnd.Integration.Tests\XXXSearch.EndToEnd.Integration.Tests.csproj" (6) on node 1 (default targets).
2018-12-23T09:48:50.2267347Z PrepareForBuild:
2018-12-23T09:48:50.2267390Z Creating directory "bin\Release\".
2018-12-23T09:48:50.2269510Z Creating directory "obj\Release\".
Creating "D:\a\1\s\src\XXXXSearch.EndToEnd.Integration.Tests\obj\Release\XXXSearch.EndToEnd.Integration.Tests.csproj.CopyComplete" because "AlwaysCreate" was specified.
2018-12-23T09:48:50.4678280Z _CopyAppConfigFile:
2018-12-23T09:48:50.4678368Z Copying file from "app.config" to "bin\Release\XXXSearch.EndToEnd.Integration.Tests.dll.config".
2018-12-23T09:48:50.4686244Z CopyFilesToOutputDirectory:
2018-12-23T09:48:50.4686316Z Copying file from "obj\Release\XXXSearch.EndToEnd.Integration.Tests.dll" to "bin\Release\XXXSearch.EndToEnd.Integration.Tests.dll".
2018-12-23T09:48:50.4691372Z XXXSearch.EndToEnd.Integration.Tests -> D:\a\1\s\src\XXXSearch.EndToEnd.Integration.Tests\bin\Release\XXXSearch.EndToEnd.Integration.Tests.dll
2018-12-23T09:48:50.4693481Z Copying file from "obj\Release\XXXSearch.EndToEnd.Integration.Tests.pdb" to "bin\Release\XXXSearch.EndToEnd.Integration.Tests.pdb".
2018-12-23T09:48:50.4755662Z Done Building Project "D:\a\1\s\src\XXXSearch.EndToEnd.Integration.Tests\XXXSearch.EndToEnd.Integration.Tests.csproj" (default targets)
Added below tasks in build.yaml file
- task: CopyFiles#2
inputs:
contents: D:/a/1/s/src/XXX.SiteSearch.EndToEnd.Integration.Tests/bin/Release/XXX.SiteSearch.EndToEnd.Integration.Tests.dll
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts#1
displayName: 'Publish E2E Artifact'
inputs:
PathtoPublish: 'D:/a/1/a/src/XXX.SiteSearch.EndToEnd.Integration.Tests/bin/Release/XXX.SiteSearch.EndToEnd.Integration.Tests.dll'
ArtifactName: e2e
Solution-1
Solution-2
Solution-3
Look at your task definition for the artifacts you're publishing:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/app.zip'
ArtifactName: app
- task: PublishBuildArtifacts#1
displayName: 'Publish deploy scripts'
inputs:
PathtoPublish: deploy
Where are you publishing your test assemblies? Answer: You're not.
If you don't publish something as an artifact, it's not going to be available down-stream in your release.
The solution is to publish your test assemblies (and other any relevant files) as a separate artifact.