I have a .netcore 3.1 Nunit project, I have build a Azure release pipeline to run the test cases on an hosted agtent and the dotnet test task fails with null pointer exception.
I am able to run the test cases on my local machine.
I tried to add the .netcore 3.1 sdk package to hosted agent.
Have you tried to run the pipeline via selfhosted agent?
According to this post, Upgrade of .NET agent for Azure Pipelines, .netcore 3.1 is gradually deprecated from microsoft-hosted agent.
I suppose that you could upgrade your project to dotnet 6.0 or test with selfhosted agent.
Related
I've been trying to find a way to run integration tests on a remote server during an Azure pipeline process. In my situation we have the pipeline running in Azure and deploying to a local server. I am wondering if there is a way to also deploy integration tests to the same server and run them and report back to Azure in the same process?
You can use self-host agent to run your pipeline. Since Azure agents cannot communicate with your localDB, you can set up a self-hosted agent on your local machine. Your localDB is accesible to the self-hosted agent.
In order to run Integration Tests in your release pipeline. You can include your Test projects or test assembly dll files in the artifacts published in your build pipeline. So that your Integration test projects are accessible to the test tasks in your release pipeline.
To Include your test files in the artifacts. You can add a second publish build artifacts task in your Build Pipeline. Specify Path to publish to the location of your test files.
Run tests in release pipeline by adding the VsTest task or other test tasks in your release pipeline. The release pipeline will download your artifacts to folder $(System.DefaultWorkingDirectory).
Visual Studio Test task and Dot NetCore CLI task automatically publish test results to the pipeline, while tasks such as Ant, Maven, Gulp, Grunt, .NET Core and Xcode provide publishing results as an option within the task. Besides you can use Publish Test Results task.
Here are some articles you can refer to:
Integration tests in ASP.NET Core
Running UAT and Integration Tests During a VSTS Build
Run automated tests from test plans
Good question. This comes up if your integration infrastructure is behind a cooperate firewall, for example.
One solution is to use a self hosted agent on that very integration infrastructure.
Another straight forward approach is to scp your integration tests to your integration infrastructure, then ssh run them, and scp the test results back. There are Pipeline Tasks for both scp and ssh.
Note that the communication in these alternatives are reversed, i.e. Hosted Agend calls Pipeline and Pipeline calls Infrastructure. Your corporate security may prefer one over the other.
I'm new to Azure pipelines and I don't understand the build process for ASP.NET Core 3.1. Like, use nuget, nuget restore, symbols etc. I've had successfully created a pipeline using hosted vs2017 but now with Azure Pipelines as agent pool the jobs I've had created before do not work anymore.
On your build pipeline definition, you have the ability to select the host type (VM image) to use while running the jobs.
So in this case I would suggest you to use the latest version of windows as VM image
- job: Windows
pool:
vmImage: 'windows-latest'
More information in this url.
I have C# library created in .net standard 2.0 and respective test project built in .netcore31. While opening the solution locally in VS2019, I am able to run all test cases and code coverage is pretty descent, however, in Azure Devops pipeline, even when I select VS2019 agent as build agent, is seems test runner is using below VS2017 for running test cases. How can we update the same to use VS2019?
Visual test task in Azure Devops Pipeline is using : ..\Microsoft Visual Studio\2017\**\Common7\IDE\Extensions\TestPlatform\vstest.console.exe
Not sure how do you configured your pipeline. By UI or YAML?
Based on my known, we does not build in Visual Studio 2017 into Windows 2019 agent. See our public source code of agent for more details.
So, I have to say that you need double check your pipeline configuration to see whether the agent selected is windows-2019.
Here is what my Visual Studio Test task log print:
If your pipeline configured by UI, please double check the Agent pool selection for Agent job and Pipeline (if it is build pipeline) are all Windows-2019.
For YAML pipeline, please ensure it is vmImage: windows-2019 or vmImage: windows-latest
I've set up the release in Azure Devops to deploy a .net core 3.1 app to a Linux App Service in Azure. This seems to push the code to Azure, but to a really weird path:
Index of /wwwroot/Content/d_C/a/1/s/[MyProject]/obj/Release/netcoreapp3.1/PubTmp/Out/
This contains all the dlls and then a wwwroot directory which has all the files & folders found in my web project.
Here is my Release set up. Anyone have any ideas why my release isn't publishing to /home/site/wwwroot/? Others have said that this is where the site should be published to. Is there something I need to set up in the Azure portal or is this a Devops thing?
This wired path should not relevant with the configuration of Azure app service deploy task or Azure portal (Just ensure the Physical path value in Azure portal is site/wwwroot).
I guess you were using Visual studio build task to build your project, right? Because I faced the similar path structure if I use VSbuild task to build my .net core app. If yes, what the others told you is correct. This is the default action if you are using Visual studio build task in Build pipeline.
Others have explained this in detail, also provided the corresponding solution. You can refer to this #1 for explanation of this default action. And check this #2 for work around.
Therefore I can safely assume that you are developing ASP.NET Core 3.0
app to be hosted in Ubuntu. Any .NET Core 3.0 (or later) application
means that you should rely on the dotnet build instead of using
VSBuild.
Also you had stated that you will host the app on Ubuntu 18.x, then
you should also run the build on Azure DevOps agent that runs on
Ubuntu. This means you should only use dotnet build in
DotNetCoreCLI#2 task, because VSBuild task only runs on Windows
based agent, not Ubuntu and it is intended to compile .NET Framework
and other platform other than .NET Core.
So, to achieve what you want, here you need using dotnet build task to build your .net core 3.1 project.
- task: DotNetCoreCLI#2
displayName: Build
inputs:
command: 'build'
projects: PATH/TO/YOUR/Project.csproj
arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release
Problem
After upgrading a .Net Core 2.2 Linux Web App to .Net Core 3.1 in Azure, the application is down with a Specified framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found error. I even went as far to create a new Linux Web App with .Net Core 3.1, and after the bash command prompt is still outputting dotnet --list-runtimes as 2.2.7.
Details
Website Down
Logstream
reporting application is down because it can't find .net core 3.1.
Created new .net core web app
3.1 linux webapp in North Central, same problem
Ensured it was running in North Central US
According to https://aspnetcoreon.azurewebsites.net/, should have full .netCore 3.1 support
Still .net core 2.2.7
opt/dotnet/runtimes lists 3, 3.0 and 3.0.0, but no 3.1`
Environment variables
My environment variables in Azure list FRAMEWORK_VERSION = lts, instead of 3.1
Publishing
This was published from an azure devops ci pipeline using an Azure AppService Deploy task. 3.1 wasn't available here, so I chose LTS
Update 1
It seems the culprit is 3.1 missing from the framework stack in Azure Devops Web App / Web Service tasks.
Whenever I publish from CI, the web app framework is updated to whatever is selected in this dropdown. If I manually go change the framework to 3.1 on the Azure Web App, the site comes up. But then the next publish it goes back down because it reverts the framework back to the settings in the ci.
New Question
How can I get the Azure Devops Release pipeline to publish a .net core 3.1 task?
Update 2
Related Azure Devops forum post
Currently being investigated as of 2/23/2020
.Net Core 3.1 deploy pipeline to Linux App Service
Suggested Workarounds
Use YML for release pipeline and manually change the version from 3.0 to 3.1, noted by answer and this thread
Upgrade from a framework dependent release to a self contained. Reference
Downgrade to .NetCore 3.0
I've run into the same situation, using the information you provided I've been able to fix the issue by setting the value manually in the Devops Pipelines Build .yml file. It seems like they are just missing the value from RunTime Stack drop down. If you manually update the build processes .yml file as seen here:
This will select the proper framework version. Hopefully this will fix your issue with the Azure Devops CI Pipeline deployment.
An easier solution is to type DOTNETCORE|3.1 into the Runtime Stack dropdown in devops. (Thanks rdavisau!)