Azure DevOps: Build 1 Project in a Multi-Project Solution - azure-devops

I'm not sure if I'm searching correctly, but I'm hoping I can get some guidance here.
Current Setup
I have one solution with two projects:
Web API project
Node.js project
I'm using Azure DevOps with 2 Builds, each with their own Releases, one for each project. Each build definition only triggers when their respective project is updated/changed.
This works great!
I've noticed that each build actually builds the entire solution. In order to not waste processing power, I'd prefer to have each project only build their own project, with a few caveats.
The Web Api project does not depend on changes to the Node.js project, however, the Node.js can depend on changes to the Web Api. Because of this, if the Web Api fails, I don't want the Node.js to build/release.
Goals
What I'm trying to do is setup my build definitions so that the Web Api build, only builds the Web Api project. Whether it completes or errors out, let the build proceed as it normally does.
However, I want the Node.js project build both the Web Api and the Node.js project, so that if the Web Api build fails, then the whole build fails even if the Node.js would not have failed.
I've tried adding a new Visual Studio Build task and select the project only, but I got the following error:
[warning]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(781,5): Warning : The OutputPath property is not set for project 'MyProject.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='release' Platform='any cpu'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.
I'm currently looking on how to fix this, but I want to pose the following questions in case I'm headed in the wrong direction.
Questions
How can I setup the build definition to only build 1 project?
Is there a different configuration I should be creating instead of the one I mentioned?
Build Definition

What I'm trying to do is setup my build definitions so that the Web Api build, only builds the Web Api project. Whether it completes or errors out, let the build proceed as it normally does.
This is the case where you want a build definition that is targeting the project file instead of the .sln. Your error is that building the .csproj requires the OutputPath property to have a value, so just add it to the MSBuild Arguments box: /p:OutputPath="$(build.binariesDirectory)\MyProject". Build.BinariesDirectory is a predefined variable, but is otherwise not a required directory value. You can use what makes sense for you.
I want the Node.js project build both the Web Api and the Node.js project, so that if the Web Api build fails, then the whole build fails even if the Node.js would not have failed.
The simplest and least sophisticated way
From what I understand about your situation, this case doesn't require any additional changes. If you build the solution, then the pipeline will fail if either of the projects are broken. The downsides to this are:
The Node.js project doesn't "get" the newest changes to the Web API "dependency" until the Node.js project is changed and CI triggers a build
If you use a build completion trigger to mitigate downside 1 above, the Web API project gets built twice even though we know it should be successful both times
The more complex and sophisticated (but elegant?) way
Set a Build completion trigger on the Node.js pipeline that will trigger a build when the Web API pipeline is successful. This is similar to what you have now with some differences. With build completion AND a CI triggers on your Node.js pipeline, the Web API build can succeed regardless of the result of the downstream Node.js, but you will be building the Node.js project even when changes are not made to that project explicitly. (This may not be what you want if you're trying to save on agent activity)
Your Node.js pipeline can then have 2 separate build steps, each targeting one of the project files. However, the step for the Web API project build can have a condition to NOT perform if the Build.Reason is BuildCompletion. This allows the Node.js to be a downstream project of the Web API, but doesn't build the Web API if we already know it's successful.
Note: depending on how your references work between these projects in this solution, you may need to add other tasks for downloading the build artifacts and what-not to make sure everything is where it should be for building.

Related

Dynamics 365 - Plugin - Newly Created Images Are Null when checked in code?

I am working on a d365 unified interface sandbox environment on a development project.
This environment was setup recently as a clone of the production d365 instance.
Today I have been adding some plugins and finding a strange issue. I can get the plugin code on record create/update firing no problem (I have pre operation create/update and post operation create/update stages defined and the correct code gets hit for each).
But the C# plugin code does not recognise any of the pre or post images that I have added.
In code when we check IPluginExecutionContext.PostEntityImages it does not contain anything.
Any of the pre existing images that were there already when the environment was cloned are firing correctly. We have a process whereby we name all of our pre and post images the exact same for every entity and I know the ones I have created are named exactly as expected.
In this example I have created a Post Operation stage Update plugin on the OOB opportunity entity with a PreImage defined against it but the code just will not recognise it.
Anyone experienced this before?
TIA
Occasionally the sandbox service seems to fail picking up updates on a plugin assembly. In those cases updating the assembly with a different assembly version (build or revision number) can help.
If not, I would advise to simply remove the complete assembly and recreate it again.
If you do not have an automated deployment process in place, follow these steps:
Create a separate solution.
Add the assembly along with its step registrations and images to the solution.
Export the solution.
Remove the assembly using the plugin registration tool.
Import the solution again.

Can I Integrate Web Tests (written in visual studio) in Azure Devops build pipeline

I have a web api (REST) project that is written in .NET and I have written a few webtests (.webtest) that test those apis.
While those tests run fine locally from visual studio, I want to integrate them into my VSTS (Azure Devops) build pipeline, so as to identify and breaking changes that could break any of those APIs.
I am not able to find any task in build pipeline which can run the webtests as part of build. I see option for running unit-tests though.
So, wanted to check what am I missing here.
You might want to find an alternative approach as this link implies it has been deprecated.
Visual Studio web performance test (.webtest file) is tied to the load
test functionality and is deprecated. Some customers have used
.webtest for other purposes such as running API tests, even though it
was not designed for that purpose. Many API testing alternatives are
available in the market. SOAP UI is a free, open source alternative to
consider, and is also available as a commercial option with additional
capabilities.
You could try to use cmd task command line to run MSTest with arguments.
Add Run Command Line step/task to execute MSTest command
Add Publish Test Results step/task
On the other hand, you can do test in Unit Test too, just send the request and check the response, related thread.
Also as Matt mentioned, since Visual Studio web performance tests (.webtest files) are tied to the load test functionality and is also deprecated. You could take a look at this blog here: Cloud-based load testing service end of life

VSTest-Task not running .NET Core 2.1 xUnit-Tests from Test-plan

I'm trying to create a release pipeline in VSTS that runs my xUnit-tests as specified in a Test Plan.
Long story short: I can't get it to work.
What I'm using:
Azure DevOps (formerly VSTS)
Visual Studio Test task (v2.*)
Test project targeting .NET Core 2.1
xunit 2.4 with xunit.runner.visualstudio 2.4
In Azure DevOps I defined a Test Plan that contains a Test Suite which contains a Test that has an Associated Automation which points to my xUnit test.
I had to use the REST API to link the test code to the Test as described here.
I can select that Test in the visual designer for the VSTest task.
When I run the release pipeline the VSTest task fails with the following error message:
DiscoveryMessage : System.IO.FileNotFoundException: Unable to find tests for D:\a\r1\a\Foo.Tests.dll. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk" and framework version settings are appropriate. Rerun with /diag option to diagnose further.
The path to the Foo.Tests.dll is correct, all required files are copied as well.
I explicitly specified the framework version in a .runsettings file (as the option Other console options doesn't work when using the Test plan option).
Specified the path to custom test adapters
used Visual Studio 2017 and Installed by Tools Installer options
Added a .NET Core Tool installer to install the correct .NET Core SDK
...and any other combination of settings I could think of.
The error message is still the same.
Any ideas what I might be missing? Your help would be greatly appreciated at this point!
After several more hours we stumbled across a web page that stated that you don't have to copy the binaries of your test project as input for the VSTest task but PUBLISH it instead. That never came to mind as vstest.console.exe runs smoothly when you point it at the binaries on a local machine.
UPDATE: We had to add a Publish Artifact task at the end of our Build Pipeline and make the Release Pipeline pick up the published artifact.

Get Build Definition response body is missing properties

I'm trying to run a request through the TFS REST API v2.0 because I would like to be able to modify the 'ProcessParameters' of a specific BuildDefinition before triggering it. This is so I can pass an argument to the specific BuildDefinition's deployment script.
Doing this work through the TFS SDK works fine, but I've had to refactor to use the REST API instead because this has to run on a production machine without Visual Studio and TFS Team Explorer.
The documentation says I should be able to specify a propertyFilter in my query, but I'm unable to get it to return more information. What I am getting is very light compared to what I'm used to working through the SDK.
Here is my request: https://{instance}/DefaultCollection/{project}/_apis/build/definitions/{id}?api-version=2.0&propertyFilters=processParameters
The response is exactly the same whether or not the "&propertyFilters=processParameters" part is set. It should be able to handle a comma-delimited list of property names but seemingly it is just ignored.
Have I found a bug, or shall we say, a discrepancy between the API documentation and the actual API? Is the 'propertyFilters' query parameter actually implemented? I can't get it to work...
Any help is highly appreciated!
It seems that you are working with XAML build definition as vNext build definition does not have ProcessParameters. However, the RestAPI Build 2.0 is mainly designed for vNext build, it can only get some basic information for XAML build definition. That means, Rest API cannot achieve the features you want for now if you are working with XAML build definition. You have to install VS&Team Explorer and use TFS SDK to do it.

Parameters for release.sh to build binaries only for current platform

I'm trying to build Kubernetes from source using the release.sh script. However I can see that it build client and server binaries for many platforms which are not useful to me. How can I say release.sh to build binaries only for my platform? I can see that KUBE_SERVER_PLATFORMS and KUBE_CLIENT_PLATFORMS checks are done in hack/lib/golang.sh script. But how can I pass those values?
Unless you're looking to cross-compile, or specifically build a release, I'd recommend using hack/build-go.sh, it will pick the host platform for you and just build on that.