build Coded UI tests in TFS 2017 + vsTest + error - build-process

I have codedUI and unit tests in my solution. Solution and the unit tests are successfully building in TFS 2017. CodedUI tests fail. I get an error.
Failed to initialize the unit test extension 'urn:CodedUITest': A unit test extension is not registered for the following attribute: Microsoft.VisualStudio.TestTools.UITesting.CodedUITestAttribute.
All the tests successfully pass in my local machine. What configuration am I missing in my build process?
kindly, help!.

According to the error info, seems the issue should more related to build agent Environment setting. Make sure you have Visual Studio and Coded UI features installed on the build agent. You could double check this by remote to the build agent and manually run Code UI in the agent machine instead of through TFS build.
If you are using Nuget Visual Studio Test Platform Installer , this is not support for now, take a look at the similar issue: VSTS build release agent unable to run Coded UI tests when using the Nuget VsTest platform
Currently Coded UI and UWP tests not support with VSTest platform
nuget package. /cc #PBoraMSFT for blog/doc and timeline for support.

Related

How to automate the process of creating app package (for "side installation") of my Xamarin UWP application in Azure devops

I have a Xamarin.Forms application which targets iOS, Android and UWP. I have built an Azure pipeline that generates my .ipa and .apk files which can be used to install on devices that support its debugging. However for UWP I am trying to generate a build that will allow side installation (not for the app store), but not sure how to do this.
In visual studio there is the option to "create app package" (see screenshot below) which generates a bunch of files including an install.ps1 script. And running this script installs the application on my machine. I would like to automate this process in my Azure Devops pipeline but not sure how to. Any help would be appreciated.
Figured out how to do this.
I used the following MSBuild Arguments in my Build solution Task:
/p:AppxBundlePlatforms="x86|x64|ARM"
/p:AppxPackageDir="$(System.DefaultWorkingDirectory)\AppxPackages\\"
/p:AppxBundle=Always
/p:UapAppxPackageBuildMode=SideloadOnly
/p:AppxPackageSigningEnabled=true
/p:PackageCertificateThumbprint="$(UWPThumbPrint)"
/p:PackageCertificateKeyFile="$(UWPCertificate.secureFilePath)"
/p:PackageCertificatePassword="$(UWPCertificatePassword)"
$(System.DefaultWorkingDirectory) may be replaced with $(Build.ArtifactStagingDirectory) if you are using an Azure machine. See this link for information on Build Arguments.
I am then able to archive the contents of $(System.DefaultWorkingDirectory)/AppxPackages with an Archive task.

Building MSI in azure devops

We have for a while been building various web projects with AzureDevops and self hosted build agents.
Today I had to add a new build, consisting of a windows service written in .net core 3.1. This service has to be installed by our customers, so we have to provide it in a friendly installable way. As some of our developers were already used to handle MSI/*.vdproj projects, they added a vdproj into the *.sln to manage that. On a developper machine, this is not a problem even with VS2019: you just have to use the relevant VS studio extension...
But when it comes to building that in a CI/CD context, this becomes a real challenge. I quickly understood that we can't use MSBuild at all for that and found some alternative using directly Visual Studio (devenv)... Inspired by this thread (still opened), I came up with the following command line:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv" [...]\MySolution.sln /build "Release" /Project MyInstallationProject
This worked fine both on my developer machine and even on the build agent machine. But when I add it into a build pipeline as a command line task, it seems to hang, and after a while I get the following result for the job:
##[error]The job running on agent <MyAgent> ran longer than the maximum time of 60 minutes. For more information, see https://go.microsoft.com/fwlink/?linkid=2077134
What can I do to make it work?
What are the best practices for generating a self installable in a CI/CD context? (Is MSI still relevant? )
As a workaround, you can try to install the extension Build VS Installer and use the task DutchWorkz - Build VS Installer(s) to build Visual Studio Installer Project in Azure Pipelines.
Here are some tickets(ticket1, ticket2) with similar issue you can refer to.

How to run mstest tests in linux machines using .NetCore?

I want to try .netcore and utilize my Linux machines for test execution purposes. Can I run specflow mstest in Linux machines from Azure DevOps pipeline using .netcore?
What steps I should follow?
There's a video guide introduced that Integrating SpecFlow with Azure DevOps using .NetCore.
It has the step by step guide on integrating a Visual Studio SpecFlow/Selenium WebDriver project with Azure DevOps. And utilizing Azure DevOps Repositories and Pipelines to execute the SpecFlow Tests.
In your scenario, you need to setup a private agent on your Linux machines and install the required components/SDKs etc to run the test. In the guide it using the VSTest, you can also try MStest.
If you cannot run it directly on the Linux machine, then you can try running in Linux container. Reference : https://github.com/techtalk/SpecFlow/issues/1662
In addition to specflow tests on a linux machine you need Mono installed in order to generate reports with SpecFlow+. Make sure you have installed Mono on the machine you are using to execute your tests (i.e. on your development machine or build server). Refer to Additional Requirements for Non-Windows Users for details.
you should try this
- task: DotNetCoreCLI#2
inputs:
command: 'test'
projects: '**/yourtest.csproj'

Clone & run existing project from github

I installed Visual Studio 2017.
I wanted to clone a repository and try in my local system.
Suppose i want to clone this. repo (Not mine.) Is it possible in one step?
Or else do i need to write step by step actions and necessary codes to run the project?
By checking NuGut package manager to auto download packages on build time will
work? I am new in ASP.Net. Is there any way to run the project in local system by just cloning.
EDIT:- Tried to restore packages
PM> dotnet restore
Welcome to .NET Core!
---------------------
Learn more about .NET Core: https://aka.ms/dotnet-docs
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't in
clude command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telem
etry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
ASP.NET Core
------------
Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other
platforms refer to the platform specific documentation.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
C:\Users\win7.system3\Documents\Visual Studio 2013\Projects\localhost_54920\localhost_54920.sln : Solution file error MS
B4249: Unable to build website project "SAMP". The ASP.NET compiler is only available on the .NET Framework version of MS
Build.
First of all, you'll need .NET Framework 4.6.1 installed in your machine.
Short answer
Having that installed, you should be able to open the project/solution with Visual Studio, build it* and run it from there.
Long answer
If that was a .NET Core project, without Visual Studio it would be as easy as:
git clone https://github.com/sarn1/example-aspnet-mvc
cd example-aspnet-mvc\ComicBookGallery
dotnet run
dotnet run will restore (dotnet restore) the dependencies, build (dotnet build) the project and run it.
However, that's not the case, so you can only:
Restore the nuget packages using Visual Studio or nuget.exe cli.
Compile it* using or msbuild (use Developer Command Prompt for Visual Studio to be able to easily access it).
Run it... from Visual Studio, which makes the rest of the process kind of worthless.
git clone https://github.com/sarn1/example-aspnet-mvc
cd example-aspnet-mvc
nuget.exe restore
msbuild /t:build
* You may need to apply these changes to make the project compile.

Running Nunit Test Cases cross platform

I have developed some End to End tests using Selenium, and Nunit.
I need to run the test cases cross-platform so I created a .net core class library project and developed the tests.
Now I am struggling with figuring how to run the tests outside visual studio.
The first step I did is publishing the project using:
dotnet publish project
Then I found out that I can run Nunit tests using nunit-console.exe, but I'm not sure that it supports cross-platform.
Is what I am trying to accomplish doable? or shall I replace Nunit with other option?
To run .Net Core tests, including NUnit tests, use the dotnet test command. It is cross-platform.
What I did to achieve running Nunit Test Cases cross platform:
1- Running dotnet publish project with specifying target runtime.
3- Running dotnet vstest with specifying file containing tests.

Resources