Search code examples
c#azure-devopsoctopus-deploy

Building specific project in a solution using Azure devops without yaml


My solution consists of multiple projects, I'm trying to build a single project(windows Project) among that solution using MSBuild and trying to generate an .exe file and publish an artifact in Azure DevOps. I tried to build the specific project using MSBuild task on Azure pipelines but it was throwing and it is throwing an error 'MSBuild.exe' exited with code '1'. in existing project i have added a new windows scheduler. only one sln file i have for all the projects. Can you please advice if i am using the correct configuration . Or i might i have to create a new sln file for windows project? click on the link to open the images.

[solution structure]

https://i.sstatic.net/Trtju.png

[pipeline congiguration] :

https://i.sstatic.net/fH8px.png

[error in pipeline]

https://i.sstatic.net/x5vxQ.png

i have added a new windows scheduler in existing project and tried creating a separate pipeline for this new project but doesnot worked i have tried couple of steps but didnot worked. after following all the steps still hit the error attaching the screen shots. now able to build but artifact didnot copied pipeln: artifact:


Solution

  • You did not provide the correct complete relative path of the project file (.csproj) to the VSBuild task.

    In the Solution field on the VS Build task, you should fill in the path "OSMart.WindowsService\OSMart.WindowsService.csproj".


    EDIT_1:

    In addition, when you want to build a particular project within a solution, it is recommended using MSBuild task.

    enter image description here

    If you project is .NET Core, you also can use the .NET Core task to building the projects via 'dotnet build' command.


    EDIT_2:

    You can add a Bash task to run the following command line before the MSBuild task.

    ls -R
    

    This command will list all the files under the current working directory. You can use it to check:

    • Whether the project files have been successfully checked out and existing under the working directory.

    • If the project files are existing, you can get the correct relative paths of the files. Use the correct relative paths to the MSBuild task.


    EDIT_3:

    Reference my sample below to configure your pipeline. I have tested this sample, and it can work as expected.

    1. The file tree in my TFVC repo.

      enter image description here

    2. Set Get Source in the pipeline.

      enter image description here

    3. Set the MSBuild task to build the specified project.

      enter image description here


    EDIT_4:

    Try to set your pipeline following the images below:

    1. Set "Get sources" like as below.

      enter image description here

    2. Set the value of 'Project' field on MSBuild task like as below. And in your TFVC repo, ensure the 'OSMart.WindowsService.csproj' file is existing under the 'OSMart.WindowsService' folder.

      enter image description here

    For "MSBuild Arguments":

    • If you have set the related properties in the .csproj file. The MSBuild will apply the properties set in the .csproj file by default.

    • If some properties are not set in the .csproj file, the MSBuild will apply the system default values.

    • If you want to overwrite some properties set in the .csproj file or the system default properties, or you want to set some extra properties, you can set them in the "MSBuild Arguments" field on the MSBuild task.