41

I am making my first build in VSTS and I have had to ask a number of questions on SO. I have now been able to restore nuget packages and build my project but now I have to ensure the artifacts are copied to the right place. My last build attempt failed for this reason: Directory 'd:\a\1\a' is empty. Nothing will be added to build artifact 'drop'. My build is defined as; enter image description here

The Copy Files enter image description here

The .Net Core build; enter image description here

And the publish; enter image description here

And from the build I get this error;

Directory 'd:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.

How do I fix this?

Vivian River
  • 31,198
  • 62
  • 198
  • 313
arame3333
  • 9,887
  • 26
  • 122
  • 205
  • It seems in VS build step, your setting for `/p` parameters in **MSBuild arguments** are incorrect. You can refer https://stackoverflow.com/questions/23112165/full-list-of-p-msdeploy-arguments-for-msbuild-from-teamcity for porperty settings. Beside If you are using private agent, you can check the path `**\bin\$(BuildConfiguration)` if it has build files. – Marina Liu May 24 '17 at 09:36
  • What's the detail build log? You can share it on the OneDrive. – starian chen-MSFT May 24 '17 at 10:07

3 Answers3

37

You need to copy and add artifact, so for me I had to add this code to the end of my .yaml file

- task: CopyFiles@2
  inputs:
    targetFolder: '$(Build.ArtifactStagingDirectory)'    

- task: PublishBuildArtifacts@1    
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
Ehsan Zargar Ershadi
  • 24,115
  • 17
  • 65
  • 95
16

First, remove ";" before Properties.EF6 (/t:;Properties.EF6;Sir.Domain).

Note: If Sir.WebUI dependency on Properties.EF6, Sir.Domain, Sir.EF6 and StandardClassLibrary, you just need to build Sir.WebUI project.

Secondly, for .Net Core task, change build command to publish and arguments is -o $(build.artifactstagingdirectory)\SIR.

Thirdly, remove Copy Files task (do not need to copy files to artifact).

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Well it has all changed now. All of the projects are dependent on Properties.API, I checked in the solution properties. But only to have that there is causing an error message for each project, the first one is; SIR\Properties.API.csproj:SIR\Properties.API.csproj(0,0): Error MSB4057: The target "Properties.API" does not exist in the project. – arame3333 May 24 '17 at 14:20
  • @arame3333 Using Properties_API instead, for example: /t:Properties_API. – starian chen-MSFT May 25 '17 at 02:16
  • What I meant to say in my last comment was that I put in /t:Properties.API and I got the error message described. On the off chance that I should take your reply literally I also tried Properties_API but of course that project does not exist and I got an error message saying so. – arame3333 May 25 '17 at 07:03
  • I am confusing now, what's your issue now. You can share the simple projects and build log on the OneDrive that can reproduce this issue. On the other hand, what I mean is that you can use /t:Properties_API if the project name is Properties.API. – starian chen-MSFT May 25 '17 at 09:19
  • OK. I do not have access to OneDrive. And when I tried /t:Properties_API I got this error message; SIR\Properties.API.csproj:SIR\Properties.API.csproj(0,0): Error MSB4057: The target "Properties_API" does not exist in the project – arame3333 May 25 '17 at 09:46
  • Just register a account (e.g. hotmail), then access OneDrive site. You also can share it anywhere that others can access. – starian chen-MSFT May 26 '17 at 01:45
  • @arame3333 Can you share sample projects on the OneDrive. (Just sln shared) – starian chen-MSFT May 26 '17 at 07:48
  • @arame3333 Can you reproduce this issue with the new solution and projects? If so, you can share this solution with projects (all files) on the OneDrive. – starian chen-MSFT May 29 '17 at 01:44
  • @arame3333 There is API folder, so, you can use /t:API\Properties_API. – starian chen-MSFT Jun 05 '17 at 02:34
  • @arame3333 The Properties.API project is a core project, so you need to use .Net Core task (Command: Publish; Project(s): $(build.sourcesdirectory)/**/*Properties.API.csproj) – starian chen-MSFT Jun 05 '17 at 03:12
  • @arame3333 In my opinion, since Properties.API is a web core project, you shouldn't add its reference to Sir_WebUI web project, you should send the request to retrieve the data. – starian chen-MSFT Jun 05 '17 at 03:19
  • I took your advice and have made progress. I am not sure whether to tick this answer and ask another question. I now have a new error message: Cannot find path /C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/Sdks/Microsoft.NET.Sdk.Publish/build/netstandard1.0/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeployPackage.targets at Commit 42b76824. I have the professional version of VS2017 rather than the enterprise so I guess that is a clue – arame3333 Jun 05 '17 at 09:38
  • @arame3333 What's the build definition like now? How do you modify your projects? – starian chen-MSFT Jun 05 '17 at 09:53
  • I removed the Properties.API reference from the SIr.WebUI project and I modified my build as you suggested; https://1drv.ms/f/s!AhERQL5GdvI4rSqb83XqL63zOCtk – arame3333 Jun 05 '17 at 10:25
  • The error message is C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(124):C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\PublishTargets\Microsoft.NET.Sdk.Publish.MSDeployPackage.targets(124,7): Error MSB4184: The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form. – arame3333 Jun 05 '17 at 14:10
  • @arame3333 For .Net Core task: Command: Publish; Projects:$(build.sourcesdirectory)/**/*Properties.API.csproj (You specified project in the command). For Visual Studio Build task, you should build Sir_WebUI project instead of Properties.API.csproj. (/t: Web\Sir_WebUI) – starian chen-MSFT Jun 06 '17 at 01:28
  • The Build part in now working. For the .Net Core task I have now set to publish (I had one already in fact). This part fails because "MSBUILD : error MSB1008: Only one project can be specified.". See https://1drv.ms/f/s!ArKf9AZKW_zWgQjF4HwUM5anNrlh. It looks like I need to make sure it only publishes the Core project and ignores the others. Is that what I need to specify in the arguments? – arame3333 Jun 06 '17 at 14:11
  • @arame3333 You need to specify Properties.API.csproj project, for .Net Core task, it just need to publish Core project. For general project (e.g. WebUI), you need to publish it through Visual Studio Build task. BTW, if more than one Core project need to be published, you can add multiple .Net Core tasks to publish them. – starian chen-MSFT Jun 07 '17 at 01:28
  • Finally got there, thank you. The place I had to change was hiding behind the "Publish Web Projects" checkbox. Now I need to understand all this a move on to deployment which may confuse me as well but time to dive in. – arame3333 Jun 07 '17 at 06:41
  • I thought I had got there but when I looked at the log I found I got the warning: "##[warning]Project file(s) matching the specified pattern were not found". I had put in for the projects: $(build.sourcesdirectory)\\Properties_API.csproj – arame3333 Jun 07 '17 at 08:49
  • @arame3333 Using $(build.sourcesdirectory)/**/*Properties_API.csproj instead. – starian chen-MSFT Jun 07 '17 at 09:16
  • I put in $(build.sourcesdirectory)/**/*Properties_API.csproj but got the same result – arame3333 Jun 07 '17 at 13:16
  • What I should be able to do is find a reference that can explain why _ ie preferred to . in filenames and another one on how to search for items using wildcards. I guess they must be around but I can't find them. – arame3333 Jun 07 '17 at 16:08
  • You can share the build log on the OneDrive. – starian chen-MSFT Jun 08 '17 at 01:24
  • Ok it is here: https://1drv.ms/u/s!ArKf9AZKW_zWgQr_uDzoKMFUHCBn (change from last post which I deleted) – arame3333 Jun 13 '17 at 07:03
  • Also how do I make the drop folder with the zip file containing the build artifacts available for deployment? In this application I have a web project and a web core api, should I have 2 separate build definitions for them? – arame3333 Jun 13 '17 at 13:44
  • @arame3333 Using $(build.sourcesdirectory)/**/*Properties.API.csproj instead (for dotnet publish task, just use the same name) – starian chen-MSFT Jun 14 '17 at 01:47
  • Regarding deployment, the published files are uploaded to the server through Publish Artifacts task, you can use this artifact to deploy web apps in release directly. (Do not need to have 2 separate build definitions) – starian chen-MSFT Jun 14 '17 at 01:50
  • I do not see where I have specified the deployment server. I also need to set up IIS (I believe this is called "provisioning" but correct me if I am wrong). Just for clarification, I have not seen a definition for "build server" - is that the same as the server I am deploying to? – arame3333 Jun 14 '17 at 06:26
  • From the last change you proposed, the build failed, see https://1drv.ms/u/s!ArKf9AZKW_zWgQuWQr77rkCA7y2K – arame3333 Jun 14 '17 at 06:29
  • @arame3333 You need to add -o argument before “$(build.artifactstagingdirector)\\SIR". (-o “$(build.artifactstagingdirector)\\SIR") – starian chen-MSFT Jun 14 '17 at 10:04
  • The build partially succeeded, the error message now is "Indexed source information could not be retrieved from 'd:\a\1\s\SIR\bin\Debug\net452\win7-x86\Properties.API.pdb'. Symbol indexes could not be retrieved." – arame3333 Jun 14 '17 at 11:18
  • So the publish symbols path section should ignore Properties.API as it is a .Net Core application. I need to work out how to configure this. I put in this search criteria; **\bin\**\S*.pdb and the build succeeded. However this excluded the Properties.Domain and Properties.EF6 projects which are NOT Core projects as well as Properties.API which is. So I need a better understanding of the search characters. Also when I attempt to put in a deployment definition, I cannot locate the Sir.WebUI.zip file. – arame3333 Jun 14 '17 at 13:52
  • @arame3333 How do you locate Sir.WebUI.zip file? The path is drop/SIR/Sir.WebUI.zip. Regarding symbol indexes issue, you may try to add multiple tasks for other projects. – starian chen-MSFT Jun 15 '17 at 01:32
  • @arame3333 I mean just for symbol indexes. Regarding release issue, you may open a new thread. – starian chen-MSFT Jun 15 '17 at 06:20
  • OK I got confused with the standard task names which are a little different to how they are when selected. But I sorted that out now. So the main thing now is the deployment and a new question on that. – arame3333 Jun 15 '17 at 08:11
3

The default build arguments don't work if you plan to use the release pipeline in azure devops.

Using the following to the MS BuildArguments in the Build step drops a package in the staging directory: $(build.artifactstagingdirectory).

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"

In the Publish Artifact step use the same location as the value:

$(build.artifactstagingdirectory)
Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51
StevieROF
  • 31
  • 1