I'm new to CI/CD and can't find any information on the internet on how to use AppCenter Test with TFS 2018. I have my Xamarin projects in TFS but I want to test them within the device cloud of AppCenter Test.
There are a couple documents on MS's docs that make it look like it's possible but for a newbie they give ZERO information on how to implement it. HERE is an example. If you look up top this document is relavant to TFS 2018.
In Azure Pipeline, you can use either YAML or the classic editor to define your pipelines. But YAML build is not supported in TFS 2018 yet.
So you need to use the classic editor to add App Center Test task to your pipeline and then refer to the Arguments in the documentation to define the task.
Here is what I did to get it working. No idea if it's correct or not, but hey, it works!
Xamarin.UITest
If you don't do the following step you'll run your tests locally and
nothing will happen, they'll just immediately exit.
First go to Tools > Options > Test > General > Active Solution then uncheck For improved performance, only use test adapters in test assembly folder or as specified in runsettings file
public class AppInitializer
{
public static IApp StartApp(Platform platform)
{
if (platform == Platform.Android)
{
return ConfigureApp.Android
// You may need to adjust the following relative path based on where you created your UITest project
.ApkFile(#"..\..\..\<AppName>\<AppName>.Android\bin\Release\<App Package Name>.apk")
// Uncomment if you are running locally and you want VS to launch/install app
//.PreferIdeSettings()
.StartApp();
}
return ConfigureApp.iOS.StartApp();
}
}
Do not add references to your Android and iOS projects like the MS
docs say. This will lead you down the path of hours of useless troubleshooting
Deploy your agent on a development windows box. Follow these instructions: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops
TFS 2018 Configuration
In TFS click into the repository of your project
Click "Build and Release"
Up top right click "+New"
Click "Continue"
Scroll down and click "Xamarin.Android"
on the next screen set the Agent queue to whatever you created ealier, probably Default
List of my build tasks
Nuget Tool Installer
.NET Core
Nuget
Xamarin.Android
MSBuild
Android signing
Node Tool Installer
Nuget
App Center Test
Here are my build steps in detail
Nuget Tool Installer
Use Nuget
version of nuget to install : 4.9.3 (this is what I noticed my VS was using)
all else defaults
.NET Core
command: restore
path to projects: **/*.csproj
all else defaults
Nuget
Command: custom
Command and arguments: restore -MsbuildPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
All else defaults
Xamarin.Android
Project: **/*Droid*.csproj
Target: (empty)
Output directory: $(build.binariesdirectory)\$(BuildConfiguration)
Configuration: $(BuildConfiguration)
MSBuild: enable Specify Location
MSBuild Location: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin
JDK Options, JDK 8 x64
all else defaults
MSBuild
Project: (fit this to match your uitest project): **/*UITest*.csproj
MSBuild version: Latest
Platform: (empty)
Configuration: $(BuildConfiguration)
MSBuild Arguments: /p:OutputPath="$(build.binariesdirectory)\$(BuildConfiguration)\test-assembly"
all else defaults
Android Signing
APK Files: $(build.binariesdirectory)\$(BuildConfiguration)\*.apk
Check sign the APK and put in your info
Jarsigner arguments: -verbose -sigalg MD5withRSA -digestalg SHA1
Check to Zipalign
Zipalign location: (empty)
all else defaults
Node Tool Installer
Version Spec: (choose whatever version you already have on your system) 10.11.0
all else defaults
Note: Prior to the next step create a new variable called
XamarinUITestVer and set the value to whatever value you want to use
for the Xamarin.UITest Nuget package you want to install. In my case
the value I set was: 2.2.7
Nuget
Command: custom
Command and Arguments (refer to note above): install Xamarin.UITest -Version $(XamarinUITestVer) -OutputDirectory "$(Agent.BuildDirectory)\Nuget"
all else defaults
App Center Test
Binary Application File Path: $(build.binariesdirectory)\$(BuildConfiguration)\*.apk
Artifacts Directory: $(Build.ArtifactStagingDirectory)\AppCenterTest
Check: 'Prepare Tests`
Test Framework: Xamarin UI Test
Build Directory: $(build.binariesdirectory)\$(BuildConfiguration)\test-assembly
Store File: (empty)
Store Password: (empty)
Key Alias: (empty)
Key Password: (empty)
Test Tools Directory: $(Agent.BuildDirectory)\Nuget\Xamarin.UITest.$(XamarinUITestVer)\tools\
Signing Information: (empty)
Additional Options: (empty)
Check: Run Tests
Authentication Method: App Center Connection
App Center Connection: (create a new connection)
App Slug: obtain this by "almost" creating a test in AppCenter. From your app in AppCenter create a New Test Run, select device(s), select Next and choose Xamarin.UITest and hit Next. Down below you'll see the --app string and this is what you use for this field.
Devices: obtain this by "almost" creating a test in AppCenter. From your app in AppCenter create a New Test Run, select device(s), select Next and choose Xamarin.UITest and hit Next. Down below you'll see the --devices string and this is what you use for this field.
all else defaults
Related
I'm trying to publish a project with the command line msbuild. My project is a Web Application and I am using Microsoft Visual Studio Professional 2017 Version 15.2 (26430.13) Release . Here's my command :
msbuild C:\Test\MyProject.csproj /p:DeployOnBuild=true /p:PublishProfile="Debug - PUBLISH PROFILE"
I've set my profile with a Platform and a Target Location, but when I execute the command, here's the returned output :
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='Debug' Pl
atform='AnyCPU'. 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.
No destination specified for Copy. Please supply either "DestinationFiles" or "Destination Folder".
The "FindUnderPath" task was not given a value for the required parameter "Path".
It seems that my profile is getting unrecognized, so it takes the default value.
Someone know why ? Thx.
It worked with this command line :
bat "msbuild \"C:\\Test\\MyProject.csproj\" /P:DeployOnBuild=true /P:PublishProfile=\"Debug - PUBLISH PROFILE"\ /P:PublishProfileRootFolder=\"C:\\Test\\Properties\\PublishProfiles\" /P:AllowUntrustedCertificate=true /P:Platform=x86 /P:Configuration=\"Debug - CONFIGURATION PROFILE"\ "
Thx !
I have a solution containing a web application and multiple database projects. While using the old XAML definition, I can compile and generate the database deployment files in TFS. With the new definition introduced in TFS 2015, I can only generate the web application deployment files.
Here are parts of the log -
2016-10-28T22:14:48.6892904Z Build started 10/28/2016 4:14:48 PM.
2016-10-28T22:14:48.8883071Z 1>Project "E:\TFS\agent\_work\1\s\Test.Client.sln" on node 1 (default targets).
2016-10-28T22:14:48.8893071Z 1>ValidateSolutionConfiguration:
2016-10-28T22:14:48.8903071Z Building solution configuration "release|any cpu".
2016-10-28T22:14:49.0633142Z ##[warning]E:\TFS\agent\_work\1\s\..\Databases\Test\Test.DB.Test.sqlproj.metaproj(0,0): Warning MSB4046: Error reading project file "..\Databases\Test\Test.DB.Test.sqlproj": Could not find a part of the path 'E:\TFS\agent\_work\1\Databases\Test\Test.DB.Test.sqlproj'.
2016-10-28T22:14:49.0643150Z 1>Project "E:\TFS\agent\_work\1\s\Test.Client.sln" (1) is building "E:\TFS\agent\_work\1\s\..\Databases\Test\Test.DB.Test.sqlproj.metaproj" (2) on node 1 (default targets).
2016-10-28T22:14:49.0693159Z 2>E:\TFS\agent\_work\1\s\..\Databases\Test\Test.DB.Test.sqlproj.metaproj : warning MSB4046: Error reading project file "..\Databases\Test\Test.DB.Test.sqlproj": Could not find a part of the path 'E:\TFS\agent\_work\1\Databases\Test\Test.DB.Test.sqlproj'.
2016-10-28T22:14:49.0823182Z 2>Done Building Project "E:\TFS\agent\_work\1\s\..\Databases\Test\Test.DB.Test.sqlproj.metaproj" (default targets).
I could not find much information on the new build definition. Anyone can help?
Thanks
We figured out what is wrong with this. Our database projects are in another folder. We need to map the server path with the local path in the Build's repository. After added this, the database project can be built.
First double check the difference of your two definitions XAML and vNext.
And check the file path E:\TFS\agent\_work\1\s\..\Databases\Test\Test.DB.Test.sqlproj on the build agent, if there are the corresponding file.
And try to build your database project directly instead of building the whole solution to see if there are some useful info for troubleshooting.
Update
Tips:
You can also build MSBuild project (.*proj) files.
If you are building a customized MSBuild project file, we recommend you use the MSBuild step instead of the Visual Studio Build step.
Source Link: Visual Studio Build
This is my first blog or query. I am very new to TFS Admin role and sonarqube tool.
We are using TFS 2013 as an ALM in our project, the project is based on .Net Application (new to .NET as well).
As per the client requirement, I am trying to integrate the "SonarQube 5.2" with the customized build process template instead of default template.
I installed the "SonarQube 5.2" on "ABC server" and my "TFS server/build agent" is on "XYZ".
I installed the SonarQube Scanner for MSBuild 2.1 on XYZ server and updated the environment variables & sonarqube runner xml accordingly.
As per the standard link I am not using default template:-http://docs.sonarqube.org/display/SCAN/From+Team+Foundation+Server+2013
and using a customized build template, which hadn't have pre/post build argument options.
So I edited in the customized build process template, added hooks for pre/post build scripts activities and updated the properties similar to the mentioned link :-
http://www.colinsalmcorner.com/post/build-script-hooks-for-tfs-2012-builds
Note: As per the above link, I didn’t update "Challenge 2 – Environment Variables" part in the process template as I am not running any powershell script only wanted to execute the MSBuild.SonarQube.Runner.exe.
Used following activity & properties within the customized process template (refer above link):
*ConvertWorkspaceItem activity, set the following properties:
• DisplayName: “Get pre-build script local path”
• Input: PreBuildScriptPath
• Result: preBuildScriptLocalPath
• Workspace: Workspace
Set the following properties in the InvokeProcess activity:
• Arguments: String.Format(" ""& '{0}' {1}"" ", prebuildScriptLocalPath, PreBuildScriptArgs)
• DisplayName: “Run pre-build script”
• FileName: “PowerShell”
• Working Directory: SourcesDirectory*
Note: Same thing done for post build script
Sequentially, I placed these pre and post script activities under "Try, Compile and Test" activity of the process template.
In the MS build definition which is using the customized process template, I am setting below values in build process parameters (location/path of runner.exe on XYZ server) :
Pre-build script path : C:\SonarQube\bin\MSBuild.SonarQube.Runner.exe
Pre-build script arguments : begin /n: /v:< project version #> /k:
Post-build script path : C:\SonarQube\bin\MSBuild.SonarQube.Runner.exe
Post-build script arguments : end
But after all these changes, my build is getting partially successful and sonarqube integration is failed with the following error:
*The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
1. The project has not been built - the project must be built in between the begin and end steps
2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
3. The begin, build or end steps have not all been launched from the same folder*
Note: On XYZ server (TFS build server) we do have MSBuild 12.0 and build is happening under SourcesDirectory as ".sonarqube" folder is getting created within the same directory.
Also on XYZ server's command prompt (within the location of SourceDirectory or where the ApplicationName.sln is available), I ran following sonarqube commands, my analysis was successful and reports generated on Sonarqube dashboard:
- MSBuild.SonarQube.Runner begin /n:<project name> /v:< project version #> /k: <project key>
- "C:\Program Files (x86)\MSBuild\12.0\Bin\Msbuild.exe" "ApplicationName.sln" /p:Configuration=Debug /p:Platform="Any CPU"
- MSBuild.SonarQube.Runner end
Kindly go through this, it will be a great help if someone can guide me and provide some concrete explanation to resolve this.
Let me know if you need any other information.
as I read in your comment:
MSBuild.SonarQube.Runner is installed on "C:\sonarquberunner\" and
MSBuild is under
"C:\Windows\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe" and my
build directory on TFS server is
"D:\data\Build\$(BuildAgentId)\$(BuildDefinitionPath)" (location of
source code for build).
You have installed MSBUILD 12, but the Build agent is calling the version 4.0
You need to modify your build process template in order to achieve that.
Find the Run MSBuild activity in your build template and set the ToolPath = “C:\Program Files (x86)\MSBuild\12.0\bin\” or the path of your MSBUILD 12
You may try to specify the /n:/k:arguments:
/k:"the project key of the SonarQube project to which the build
definition relates"
/n:"the project name of the SonarQube project"
Also, instead of Post-build script path and Post-build script arguments, try to set the Post-test script path to the full path to MSBuild.SonarQube.Runner.exe, and set the Post-test script arguments to end.
Check the screenshot below:
I'm trying to get our TFS2015 Build (TFSBuild vnext) going along with VS Team Services.
Thus far most blogs and documentation has been helpful, except for when trying to build a project that uses custom package sources for NuGet automatic package restore.
I've successfully deployed an a Team Services Build Agent (the new mechanism for builds) and all seemed to go well until the build task to Restore NuGet packages failed.
The failure was due to custom/private package source not being picked up from the installed VS configuration, so those packages could not be found. The traditional packages from the default NuGet package feed did restore without issue.
How do I specify the additional package sources for NuGet to use when using an agent?
EDIT: vcastro asked about the NuGet Installer build step and defining paths in the configuration of that build step. The above is using the Visual Studio Build step and the integrated option to have NuGet restore packages. Refer this image for reference:
Alternatively you could also add a NuGet Installer build step before the Visual Studio Build step in your build configuration to restore all NuGet packages.
There you can pass the location of your private repo as argument to nuget.exe:
-source "https://www.nuget.org/api/v2/;http://mynugetserver"
I've scrounged the web with little success, but after fiddling the following will help:
OK It seems that the package sources configured for NuGet.config is stored per user account, e.g.
c:\Users\<<username>>\AppData\Roaming\NuGet\NuGet.config
My issue was harder to resolve, because the build agent was running as a Windows Service under the Local System account. So to get NuGet configuration to for the build, I had to use the following path instead:
64-bit Windows C:\Windows\SysWOW64\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config
32-bit Windows C:\Windows\System32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config
You may need to have elevated permissions in order to create the NuGet subfolder and NuGet.Config file.
Note: I have no solution for using the Local Service account. The above only works for the Local System (or an actual user) account.
Add a NuGet.config to your project that specifies an alternate package location. The rules for resolution are well-defined and explained in the official documentation.
There is a new VSTS Task called "NuGet Installer" this allows you to check in your NuGet.config file and specify the different package sources. Run this task before you run MSBuild.
If you are using the VSTS NuGet Feed you will need to add the build service account to the feed to enable downloading of packages https://www.visualstudio.com/get-started/package/use/common-identities
One solution (works for me) is change account for tfs 2015 build agent service (on my build machine VSO Agent tsf.Agent-PC) to tfsagent, for example, and add Nuget.config to the C:\Users\tfsagent\AppData\Roaming\Nuget. That's all!
Specify your custom NuGet feed URL’s in the solution’s nuget.config file. Do not store any usernames & passwords in this file.
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="MyCompany" value="https://nuget.mycompany.com:443/nuget" />
Create username & password variables in your build definition in VSTS. Variables can be encrypted and will not be displayed in any of the build log outputs. Here I'll create MyCompanyNugetUser and MyCompanyNugetPwd variables.
In our build steps, we add a Powershell script as the first action, this will read the username & password variables and update the user level nuget.config file on the build machine. Below is the code snippet from my inline Powershell script:
Arguments:
$(MyCompanyNugetUser) $(MyCompanyNugetPwd)
Script:
param($user, $pwd)
$nugetFile = "$ENV:AGENT_HOMEDIRECTORY\agent\worker\tools\nuget.exe"
Write-Output "Looking for nuget.exe in $nugetFile"
if (-not (Test-Path $nugetFile))
{
Write-Error "nuget.exe could not be located."
return
}
Write-Output "nuget.exe located"
$cmd = "$nugetFile sources add -name MyCompany -source https://nuget.mycompany.com:443/nuget -username $user -password $pwd -StorePasswordInClearText"
Write-Output $cmd
iex $cmd
Next, we just continue to execute the default NuGet Restore step from Microsoft’s templates
More here: https://codingcase.com/2016/07/27/vsts-build-setup-custom-nuget-feeds-with-authentication/
HTH
In the RTM of Team Foundation Server 2015 you have to add a build step of the type "NuGet Installer", and restore the packages of the Solution file before you run the actual build process. In this task you can pass the argument -ConfigFile path/to/nuget.config which contains your repository path.
For Example:
<configuration>
<packageSources>
<add key="Internal Nuget" value="\\srv-nuget\Repo" />
</packageSources>
</configuration>
If you are having trouble getting this to work on UWP ONLY, then ensure that you have the CASE of the package name spelt correctly. If the case is wrong, then (for UWP only) our build server fails the build.
for instance, if you have a package called Com.Company.Components and update the package using "install-package com.company.components" (note the case of the initial letter) then the UWP build on the build server may fail to find the package in your local store.
My team is starting to take on the challenge of automating our Build-Deploy-Test process, beginning with the build.
Right now we have Build Definitions configured in TFS that will publish our site to our servers using Web Deploy, and this is working; however, we aren't able to keep an archive of the packages that would be created with each build because when we turn on package creation with the MSBuild parameter /p:CreatePackageOnPublish=true, the build fails on silly NTFS file length constraints.
Exception Message: TF400889: The following path contains more than the allowed 259 characters: \\builds.tfs.company.com\builds\Project.Dev.Nightly\Project.Dev.Nightly_20130630.6\Debug\_PublishedWebsites\Project.Middleware.Service_Package\Archive\Content\C_C\Builds\1005\Project\Project.Dev.Nightly\Sources\Source\Multi\Middleware\Project.Middleware.Service.
Is there a way that we can break the Archive folder out somewhere else?
You can edit the path by using the _PackageTempDir argument for MSBuild.
Just add _PackageTempDir=D:\{desired dir structure} when you're passing in MSBuild arguments.
More full explanation of this property can be found here -
VS2010 Web Deploy: how to remove absolute paths and automate setAcl?