How to exclude WinPhone from the build - xamarin.forms

I have a Xamarin.Forms application, which supports iOS, Android, and UWP. I have an issue with the latter, when I am trying to submit it to Windows Store using Azure pipeline. I keep getting an error:
Status 400: {"code":"InvalidParameterValue","data":[],"details":[],"message":"AllowTargetFutureDeviceFamilies was not updated with all supported platform(s): [Desktop, Mobile, Xbox, Holographic]","source":"Ingestion Api","target":"allowTargetFutureDeviceFamilies"} CorrelationId: d6b9d6a2-6906-4908-9832-28c8f3c45a36
Here is how this looks at the Partner Center:
It looks like the issue has something to do with app.xap and Windows Phone. We are not supporting Windows Phone, so here is how it looks in our Package.appxmanifest:
<Dependencies>
<TargetDeviceFamily Name="Windows.Mobile" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
And here is my UWP project's target plaftorm version:
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
And here is some of my pipeline information:
steps:
- task: richardfennellBM.BM-VSTS-Versioning-Task.Version-APPX-Task.VersionAPPX#2
displayName: 'Bump UWP Versions'
inputs:
VersionNumber: '$(Build.BuildNumber).0'
InjectVersion: true
variables:
BuildConfiguration: 'Release'
steps:
- task: VSBuild#1
displayName: 'Build project **\*UWP.csproj'
inputs:
solution: '**\*UWP.csproj'
msbuildArgs: '/p:AppxBundlePlatforms=x86
/p:AppxPackageDir="$(Build.ArtifactStagingDirectory)\AppxPackages\\"
/p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload'
platform: x86
configuration: '$(BuildConfiguration)'
clean: true
How can I submit my app? How can I get rid of Windows Phone, if that is the problem?

Related

First time Azure DevOps user, tips on what I could do better in my build pipeline

I work for a small company and we are just starting to get our DevOps pipeline setup. The codebase is about 20 projects in a Visual Studio Solution. Some of these projects' frameworks are .Net 5 and others are .Net Framework 4.8. We are currently in the process of updating but for now we need to use what we have. The following is my attempt at a build pipeline. It runs and I think it works. But I wanted to get more professional opinions on what I can do better because I feel like it is pretty newb.
Here is my yml file:
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- develop
pool:
vmImage: 'windows-latest'
variables:
solution: '**/MySolution.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
displayName: 'Install NuGet'
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'select'
vstsFeed: '6010f35a-7ea3-4aa2-8264-60e3a5f02e6f'
- task: UseDotNet#2
displayName: 'Use .NET Core sdk 5.0.404'
inputs:
packageType: 'sdk'
version: '5.0.404'
includePreviewVersions: true
#Using DotNet and NuGet restore because without doing both the build breaks.
- task: DotNetCoreCLI#2
displayName: 'DotNet Restore'
inputs:
command: 'restore'
projects: '**/*.csproj'
feedsToUse: 'select'
vstsFeed: '6010f35a-7ea3-4aa2-8264-60e3a5f02e6f'
#Specifying older version to work with our older project dependencies.
- task: NodeTool#0
displayName: 'Use Node version 14.x'
inputs:
versionSpec: '14.x'
#The CleanWebsitesPackage lines are weird, I added them because the build was deleting most of the .Net Framework 4.8 project outputs
#when I looked in the logs it showed these steps were the ones doing the deleting.
#By pointing them at nothing it doesn't delete.
- task: VSBuild#1
displayName: 'VS Build'
inputs:
solution: '$(solution)'
msbuildArgs: '
/p:DeployOnBuild=true
/p:WebPublishMethod=package
/p:PackageAsSingleFile=true
/p:SkipInvalidConfigurations=true
/p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip"
/p:DeployIisAppPath="Default Web Site"
/p:CleanWebsitesPackageCoreDependsOn=""
/p:CleanWebsitesPackageDependsOn=""'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: ExtractFiles#1
inputs:
archiveFilePatterns: '$(build.artifactStagingDirectory)\WebApp.zip'
destinationFolder: '$(build.artifactStagingDirectory)\WebApp'
cleanDestinationFolder: true
overwriteExistingFiles: true
- task: DeleteFiles#1
inputs:
SourceFolder:
Contents: '(build.artifactStagingDirectory)\WebApp.zip'
- task: PublishPipelineArtifact#1
inputs:
targetPath: '$(build.artifactStagingDirectory)'
# targetPath: '$(Pipeline.Workspace)' #Uncomment to publish entire directory
artifact: 'drop'
publishLocation: 'pipeline'
I would probably keep things simple but here are few suggestions i can think off.
If the scope of this pipeline is to become a multi-stage pipeline in the future then you could utilize stages to define multiple stages of your pipeline
stages:
stage: A
jobs:
job: A1
job: A2
stage: B
jobs:
job: B1
job: B2
Reference: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/stages?view=azure-devops&tabs=yaml
You can use templates to define reusable content, logic, and parameters.
Reference: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

Devops Pipeline for multiple Azure Functions

I have a solution containing 2 Azure Functions.
In my build Pipeline I create 2 different zip and "seem" fine to me.
Then I use those zip in my release pipelines, everything seems fine (no error), but when I go in the azure portal, I don't see any function available.
While App Insights only gives me this : Loading functions metadata; 0 functions loaded.
What could be wrong?
build pipeline:
name: Azure Pipelines
steps:
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
projects: '**/*.csproj'
- task: DotNetCoreCLI#2
displayName: 'Func1 Publish Zip'
inputs:
command: publish
publishWebProjects: false
projects: '$(System.DefaultWorkingDirectory)/SolutionName/Function1/Function1.csproj'
arguments: '--output publish_output\Function1 --configuration Release'
modifyOutputPath: false
- task: PublishPipelineArtifact#1
displayName: 'Func1 Publish Artifact'
inputs:
targetPath: 'publish_output\Function1\'
artifact: Func1Artifact
- task: DotNetCoreCLI#2
displayName: 'Func2 Publish Zip'
inputs:
command: publish
publishWebProjects: false
projects: '$(System.DefaultWorkingDirectory)/SolutionName/Function2/Function2.csproj'
arguments: '--output publish_output\Function2 --configuration Release'
modifyOutputPath: false
- task: PublishPipelineArtifact#1
displayName: 'Func2 Publish Artifact'
inputs:
targetPath: 'publish_output\Func2\'
artifact: Func2Artifact
1 of the release pipeline :
steps:
- task: AzureFunctionApp#1
displayName: 'Deploy Function 1'
inputs:
azureSubscription: '$(Parameters.AzureSubscription)'
appType: '$(Parameters.AppType)'
appName: '$(Parameters.AppName)'
package: '$(System.DefaultWorkingDirectory)/xxx Build/Func1Artifact'
it is a continuation of this post :
Azure Devops Release pipeline(s) for multiple Azure Functions
EDIT:
log for deploy function:
2021-06-29T08:53:49.6084003Z ##[section]Starting: Deploy Func1 Function
2021-06-29T08:53:49.6208602Z
====
2021-06-29T08:53:49.6209159Z Task : Azure Functions
2021-06-29T08:53:49.6209483Z Description : Update a function app with
.NET, Python, JavaScript, PowerShell, Java based web applications
2021-06-29T08:53:49.6209969Z Version : 1.187.0
2021-06-29T08:53:49.6210422Z Author : Microsoft Corporation
2021-06-29T08:53:49.6211044Z Help :
https://aka.ms/azurefunctiontroubleshooting
2021-06-29T08:53:49.6211592Z
====
2021-06-29T08:53:50.6211817Z Got service connection details for Azure
App Service:'func1-dev'
2021-06-29T08:53:52.6469625Z Deleting App Service Application settings.
Data: ["WEBSITE_RUN_FROM_ZIP","WEBSITE_RUN_FROM_PACKAGE"]
2021-06-29T08:54:17.4575237Z Updated App Service Application settings
and Kudu Application settings.
2021-06-29T08:54:17.5343524Z Package deployment using ZIP Deploy
initiated.
2021-06-29T08:54:38.8090909Z Deploy logs can be viewed at https://func1-
dev.scm.azurewebsites.net/api/deployments/xxxx/log
2021-06-29T08:54:38.8091932Z Successfully deployed web package to App
Service.
2021-06-29T08:55:00.5393032Z Successfully added release annotation to
the Application Insight : func1-dev
2021-06-29T08:55:10.1885833Z Successfully updated deployment History at
https://func1-dev.scm.azurewebsites.net/api/deployments/xxx
2021-06-29T08:55:22.5301509Z App Service Application URL: http://func1-
dev.azurewebsites.net
2021-06-29T08:56:06.1898662Z ##[section]Finishing: Deploy Func1 Function

Correct way to use Publish Pileine Artifact , Download Pipeline Artifact and Deploy to Azure webapp

First of all I'm building a proof of concept demonstrating a build and deploy (CI/CD0 in Azure Devops.
It is and ASP.NET 4.8 WebApp.
Using the tasks like Download Build Artifacts and Publish Build Artifacts and Deploy Azure Webapp I have no problems. But I read that the aforementioned tasks are being deprecated, but as soon as I use the new Publish PipeLine Artifact Download Pipeline Artifact and then deploy Azure Web App it doesn't work. It publishes and downloads the artifact but at the deploy azure web app stage it says it can't find the artifact. Truth is I have no idea what to fill out there. Googling everything I could find.
The azure deploy task gives me this error: #[error]Error:
No package found with specified pattern: D:\a\1\drop*.*Check i
I see the artifact actually downloads in the Download Pipelineartifact :
Download artifact to: D:\a\1
The actual question would be, what do I fill out the AzureWebApp#1 task with the package: '$(Pipeline.Workspace)/drop/.' (This is wrong but how do I make this right ?)
Very much appreciated
john
Here is my YAML file code:
trigger:
- none
stages:
- stage: Build
pool:
vmImage: 'windows-latest'
jobs:
- job: Build
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishPipelineArtifact#1
inputs:
targetPath: '$(Pipeline.Workspace)'
artifact: 'drop'
publishLocation: 'pipeline'
- stage: Deploy
pool:
vmImage: 'windows-latest'
jobs:
- job: Deploy
steps:
- task: DownloadPipelineArtifact#2
inputs:
buildType: 'current'
artifactName: 'drop'
targetPath: '$(Pipeline.Workspace)'
- task: AzureWebApp#1
inputs:
azureSubscription: 'tofreewebapp'
appType: 'webApp'
appName: 'freewebappdave'
package: '$(Pipeline.Workspace)/drop/*.*'
deploymentMethod: 'auto'
#[error]Error: No package found with specified pattern: D:\a\1\drop*.*
In the DownloadPipelineArtifact task, you downloaded the artifact to the Pipeline.Workspace path, but in the AzureWebApp task, the package path you specified is $(Pipeline.Workspace)/drop/*.*. So the package was not found in the drop folder.
You can change the package path to $(Pipeline.Workspace):
- task: AzureWebApp#1
inputs:
azureSubscription: 'tofreewebapp'
appType: 'webApp'
appName: 'freewebappdave'
package: '$(Pipeline.Workspace)'
deploymentMethod: 'auto'

Azure Devops + Coverlet + SonarQube shows 0%

Good morning,
Sorry to bother you, I have a problem and I have no leads.
I have a pipeline on Azure DevOps where I use coverlet to generate a code coverage report when I use the command "dotnet test".
Indeed, the report is well generated.
At first, in the "Prepare analysis on SonarQube" step, I set the variable "sonar.cs.opencover.reportsPaths="$(Agent.TempDirectory)/coverage.opencover.xml".
And yet the end in my SonarQube there is 0% code coverage... I don't know what to do or any leads...
Thanks
I cannot reproduce above issue. And it is hard to troubleshoot since you did not share your configuration for dotnet test task or sonarqube prepare task.
I created a test project and the coverage was successfully published to my sonarqube server. You can refer to below my steps.
1, create sonarqube server and configure my projectName and projectKey (I use azure sonarqube container instance, check here for details).
2, configure sonarqube service connection in azure devops.
3, create build pipeline. I use yaml pipeline.
In Prepare Analysis Configuration task, I choose to Use standalone scanner, and Mode is Manually provide configure. And I set variable sonar.cs.opencover.reportsPaths="$(Agent.TempDirectory)/coverage.opencover.xml".
Below screenshot is the task's setting in classic ui view.
In my dotnet test task I set the arguments as below, and specifically output the coverage result to $(Agent.TempDirectory)/ folder.
arguments: '--configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutput=$(Agent.TempDirectory)/ /p:CoverletOutputFormat=opencover'
Below is the full content of my azure-pipelines.yml file.
trigger: none
jobs:
- job: 'Tests'
pool:
vmImage: windows-latest
variables:
buildConfiguration: 'Release'
continueOnError: true
steps:
- task: SonarQubePrepare#4
displayName: 'Prepare analysis on SonarQube'
inputs:
SonarQube: sonarlevi
scannerMode: CLI
configMode: manual
cliProjectKey: myproject2
cliProjectName: myproject2
extraProperties: |
sonar.cs.opencover.reportsPaths="$(Agent.TempDirectory)/coverage.opencover.xml"
- task: DotNetCoreCLI#2
inputs:
command: restore
projects: '**\*.csproj'
- task: DotNetCoreCLI#2
inputs:
command: custom
custom: tool
arguments: install --tool-path . dotnet-reportgenerator-globaltool
displayName: Install ReportGenerator tool
- task: DotNetCoreCLI#2
displayName: Test .NET
inputs:
command: test
projects: '**\*Test*.csproj'
publishTestResults: false
arguments: '--configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutput=$(Agent.TempDirectory)/ /p:CoverletOutputFormat=opencover'
condition: succeededOrFailed()
- task: SonarQubeAnalyze#4
displayName: 'Run Code Analysis'
- task: SonarQubePublish#4
displayName: 'Publish Quality Gate Result'
I did a lot of things to finally managed to get the coverage working but I think that the problem was the "ProjectGUID" missing in each .csproj of my solution making the projects ignored by SonarQube scanner.
I also upgraded from SonarQube 6.2 to 8.1 at the same time which may have solved the problem.
My steps remained unchanged to make this work.

Android build failing on Azure DevOps(VSTS) build agent with Error APT0000: Error retrieving parent for item

We have a Xamarin.Android apps built using Xamarin Forms and shared code (.NET Standard 2.0) and trying to build it on our build server where it continuously failing with following errors:
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'colorAccent'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'colorPrimary'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'colorPrimaryDark'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'windowActionBar'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'windowActionModeOverlay'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'windowNoTitle'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'colorAccent'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.
Following are notable points:
We recently moved from Xamarin.iOS and Xamarin.Android UI to Xamarin.Forms UI. The build agent is able to build the previous builds successfully.
The app builds successfully on our local dev machines (tried on 2 different) in release mode.
Also tried building the code by simply downloading the app on Build Server and running via VS and it build successfully.
Xamarin.Android.Support.v7 and Xamarin.Android.Support.v4 are included.
Solutions I've tried so far include:
Making sure the Support libraries and target framework are on same
level. (API 25)
Making sure the shared code builds before android code.
Updated the Android SDKs on Build Server. Android config is same as
on my dev machine.
Tried with different version of API
Cleared content of C:\Users\Admin\AppData\Local\xamarin
Rebuild, Restart, Clean bin and obj and other regular stuff
Been struggling with this for 2 days now. ANy help will be much appreciated.
Following is the YAML config that helped me finally build the project.
resources:
- repo: self
clean: true
queue:
name: Default
demands:
- MSBuild
- Xamarin.Android
- JDK
- AndroidSDK
variables:
BuildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand#2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.restorePkgSolution)'
- task: XamarinAndroid#1
displayName: 'Build Mobile.Android'
inputs:
projectFile: Mobile.Android/Mobile.Android.csproj
outputDirectory: '$(build.binariesdirectory)/$(BuildConfiguration)'
configuration: '$(BuildConfiguration)'
- task: AndroidSigning#1
displayName: 'Signing and aligning APK file(s) $(build.binariesdirectory)/$(BuildConfiguration)/*.apk'
inputs:
files: '$(Parameters.appFiles)'
keystoreFile: '<path>'
keystorePass: <password>
keystoreAlias: <alias>
keyPass: <pass>
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.binariesdirectory)/$(BuildConfiguration)'
Difference between this pipeline and the previous pipeline which was failing is:
I was running dotnet restore on the solution in previous pipeline before running MSBuild which I am not doing here.
I was building the solution before while here I am building android csproj. IMO, sln should build because the in release config of android, I've set it to only build with android and shared projects.
Clean in all steps was set to be true, absence of which was causing a different issue TaskABI not found.
In previous pipeline, I was running NuGetInstaller against what I am doing now which is NuGetTollInstaller and then just running nuget restore on it.
So I am still not 100% sure what I was doing wrong but my best guess would be that nuget restore was either not working properly or clean in next steps was cleaning the nuget.
If someone wants to investigate further, most welcome. I'll post definite answer if I figure it out but for now this YAML is working.

Resources