0

Let’s say I have a directory structure like this in an Azure DevOps repo:

Main/
  - A/  
    - *.csproj
  - B/
    - *.csproj   
  - C/
    - *.csproj  

Each subfolder has a .csproj file. I want to compile the Main/A/ folder and save the build results (artifacts?) somewhere, be it a folder or something else. How do I tell Azure to build that precise Main/A/*.csproj file and do I need to use /p:OutputPath inside the VSBuild@1 task, or do I need to use some other Azure task?

Pine Code
  • 2,466
  • 3
  • 18
  • 43

1 Answers1

0

How do I tell Azure to build that precise Main/A/*.csproj file and do I need to use /p:OutputPath inside the VSBuild@1 task

If you're using classic UI, you need to unlink the default solution:

enter image description here

And then choose the A project by the browse option:

enter image description here

If you're using Yaml format, you should use something like solution: A/A.csproj to specify which project to build.

Note:

Since now we're building single project instead of whole solution, we should use Project Configuration instead of Solution Configuration. any cpu is Solution Platform instead of Project Platform(AnyCPU). So we should make sure we're building single project with AnyCPU if we want to build one project with this setting.

If you got error The OutputPath property is not set for project 'A.csproj', that indicates you should use valid project configuration. In your case, if you're using any cpu, change it to AnyCPU.

In addition:

1.To publish the build results as build artifacts for further use. You can use Copy Files task and Publish Build Artifacts task like this:

Copy Files Task.

enter image description here

Publish Build Artifacts

enter image description here

Then you can download the Test.zip in Summary tab from build log page. Also, you can use this artifact in release pipeline by using download artifacts task.

  1. Check this, if you're trying build code project instead of whole solution. You can consider MSBuild Task. They(Msbuild task,VS Build task) both calls msbuild.exe to do the build job.

Hope all above helps :)

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • Thanks. Now an error shows at the MSBuild stage of the pipeline: `Error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.` In my YAML file I already have the `NuGetCommand@2` with the `command: 'restore'` option. – Pine Code Feb 21 '20 at 10:35
  • 1.Are you restoring whole solution? Please check the log of nuget restore task to make sure the packages are installed successfully. 2. What's the target framework, if they's .net core and .net standard projects, [dotnet restore](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops) task is more suitable 3. Try specifying the nuget tool version you use, use Nuget Tool Installer task with nuget.exe version 5.3.1 or what. (default 4.4 is too old.) – LoLance Feb 21 '20 at 10:47
  • I successfully fixed the problem, deleting a folder called `Migration...` which I don’t understand why was there. I have one more problem. I want to build the `A/*.csproj` project, I want make Azure to give it a specific name, including `$(Date:yyy)`, but this error shows when I use it: `Error MSB4184: The expression ... cannot be evaluated. The path is not of a legal form.` – Pine Code Feb 21 '20 at 16:27
  • @FrancoScarpa It seems your original issue is resolved, you could consider adding it as answer. And open a new thread about the new issue, cause they're different issues. – LoLance Feb 25 '20 at 13:50