I am trying to use azure devops to setup automatic build for my xamarin android application.
I used the default Xamarin.Android build template
# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/xamarin
trigger:
- master
pool:
vmImage: 'windows-latest'
demands:
- MSBuild
- Xamarin.Android
- JDK
variables:
buildConfiguration: 'Release'
outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '**/*.sln'
- task: XamarinAndroid#1
inputs:
projectFile: '**/*droid*.csproj'
outputDirectory: '$(outputDirectory)'
configuration: '$(buildConfiguration)'
This gives me an error on build
2020-03-26T09:12:32.2752297Z Generating MSBuild file d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\obj\XamarinFormsTry.Android.csproj.nuget.g.props.
2020-03-26T09:12:32.2752837Z Generating MSBuild file d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\obj\XamarinFormsTry.Android.csproj.nuget.g.targets.
2020-03-26T09:12:32.2753312Z Writing assets file to disk. Path: d:\a\1\s\XamarinFormsTryStandard\obj\project.assets.json
2020-03-26T09:12:32.2753766Z Writing assets file to disk. Path: d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\obj\project.assets.json
2020-03-26T09:12:32.2754231Z Writing cache file to disk. Path: d:\a\1\s\XamarinFormsTryStandard\obj\project.nuget.cache
2020-03-26T09:12:32.2754658Z Restore completed in 47.34 sec for d:\a\1\s\XamarinFormsTryStandard\XamarinFormsTry.csproj.
2020-03-26T09:12:32.2755110Z Writing cache file to disk. Path: d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\obj\project.nuget.cache
2020-03-26T09:12:32.2755614Z Restore completed in 47.57 sec for d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj.
2020-03-26T09:12:32.2755964Z
2020-03-26T09:12:32.2756107Z NuGet Config files used:
2020-03-26T09:12:32.2756322Z d:\a\1\Nuget\tempNuGet_19.config
2020-03-26T09:12:32.2756470Z
2020-03-26T09:12:32.2756630Z Feeds used:
2020-03-26T09:12:32.2756825Z https://api.nuget.org/v3/index.json
2020-03-26T09:12:32.2756980Z
2020-03-26T09:12:32.2757113Z Installed:
2020-03-26T09:12:32.2757302Z 1 package(s) to packages.config projects
2020-03-26T09:12:32.2757610Z 13 package(s) to d:\a\1\s\XamarinFormsTryStandard\XamarinFormsTry.csproj
2020-03-26T09:12:32.2758035Z 169 package(s) to d:\a\1\s\XamarinFormsTry\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj
2020-03-26T09:12:32.2773237Z ##[section]Finishing: NuGetCommand
2020-03-26T09:12:32.2807591Z ##[section]Starting: XamarinAndroid
2020-03-26T09:12:32.2947509Z ==============================================================================
2020-03-26T09:12:32.2947864Z Task : Xamarin.Android
2020-03-26T09:12:32.2948151Z Description : Build an Android app with Xamarin
2020-03-26T09:12:32.2948500Z Version : 1.166.0
2020-03-26T09:12:32.2948736Z Author : Microsoft Corporation
2020-03-26T09:12:32.2949074Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/xamarin-android
2020-03-26T09:12:32.2949464Z ==============================================================================
2020-03-26T09:12:34.4220559Z ##[command]"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2020-03-26T09:12:34.4661105Z ##[command]"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -products Microsoft.VisualStudio.Product.BuildTools -latest -format json
2020-03-26T09:12:34.5348014Z ##[command]"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [16.0,17.0) -latest -format json
2020-03-26T09:12:34.7801263Z ##[warning]Unable to find MSBuild version '15.0' for architecture 'x86'. Falling back to version '16.0'.
2020-03-26T09:12:34.8662182Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=b1e39c46-8802-47e2-b5ab-4bec5fda9203|SolutionDir=d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android"*ForwardingLogger,"D:\a\_tasks\XamarinAndroid_27edd013-36fd-43aa-96a3-7d73e1e35285\1.166.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:configuration="Release" /p:_MSDeployUserAgent="VSTS_efe7950b-580b-467b-8a98-19b6043eee2e_build_1_0" /t:PackageForAndroid /p:OutputPath="d:\a\1\b/Release"
2020-03-26T09:12:34.9957257Z Build started 3/26/2020 9:12:34 AM.
2020-03-26T09:12:35.2054286Z Project "d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj" on node 1 (PackageForAndroid target(s)).
2020-03-26T09:12:35.2062946Z _CleanIntermediateIfNuGetsChange:
2020-03-26T09:12:35.2066241Z Creating directory "obj\Release\90\stamp\".
2020-03-26T09:12:35.2070062Z Creating "obj\Release\90\stamp\_CleanIntermediateIfNuGetsChange.stamp" because "AlwaysCreate" was specified.
2020-03-26T09:12:35.8847743Z _ResolveSdks:
2020-03-26T09:12:35.8850229Z Found Java SDK version 1.8.0.
2020-03-26T09:12:36.3595388Z Found Java SDK version 1.8.0.
2020-03-26T09:12:36.8133556Z ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(752,2): Error : AndroidManifest file does not exist
2020-03-26T09:12:36.8136850Z C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(752,2): error : AndroidManifest file does not exist [d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj]
2020-03-26T09:12:36.8167951Z Done Building Project "d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj" (PackageForAndroid target(s)) -- FAILED.
2020-03-26T09:12:36.8205677Z
2020-03-26T09:12:36.8208249Z Build FAILED.
2020-03-26T09:12:36.8258005Z
2020-03-26T09:12:36.8270145Z "d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj" (PackageForAndroid target) (1) ->
2020-03-26T09:12:36.8274063Z (_ValidateAndroidPackageProperties target) ->
2020-03-26T09:12:36.8277799Z C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(752,2): error : AndroidManifest file does not exist [d:\a\1\s\MigrationBackup\b36c964d\XamarinFormsTry.Android\XamarinFormsTry.Android.csproj]
2020-03-26T09:12:36.8279308Z
2020-03-26T09:12:36.8281145Z 0 Warning(s)
2020-03-26T09:12:36.8284488Z 1 Error(s)
2020-03-26T09:12:36.8286684Z
2020-03-26T09:12:36.8290589Z Time Elapsed 00:00:01.83
2020-03-26T09:12:36.9547149Z ##[error]Process 'msbuild.exe' exited with code '1'.
2020-03-26T09:12:37.1765717Z ##[section]Finishing: XamarinAndroid
2020-03-26T09:12:44.6607030Z ##[section]Starting: Checkout XamarinFormsTry#master to s
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(752,2): Error : AndroidManifest file does not exist
Process 'msbuild.exe' exited with code '1'.
I know that my project builds just fine as I can build it on my mac and pc using Visual studio for mac and Visual Studio 2019
and
I am also using https://appcenter.ms (Microsoft AppCenter) for analytics and that too provides a build on commit option. Even that builds just fine using a similar build agent process.
I have tried making a copy of AndroidManifest.xml and placing it in the root but that does not work either.
here is the configuration block from the .proj file for the Xamarin.Android project
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C6CD5F2A-47C8-4A53-9729-91C88CEEB870}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>XamarinFormsTry.Droid</RootNamespace>
<AssemblyName>XamarinFormsTry.Android</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidApplication>true</AndroidApplication>
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<AndroidStoreUncompressedFileExtensions />
<MandroidI18n />
<JavaMaximumHeapSize />
<JavaOptions />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<AndroidKeyStore>false</AndroidKeyStore>
<AndroidSigningKeyStore>*******</AndroidSigningKeyStore>
<AndroidSigningStorePass />
<AndroidLinkMode>None</AndroidLinkMode>
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
</PropertyGroup>
It probably is something silly on my end, but I am unable to find help on google or figure it out myself.
So for anyone who has a xamarin.forms .net standard way kind of project and is running into a similar error here is what fixed it for me.
the original pipline
# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/xamarin
trigger:
- master
pool:
vmImage: 'windows-latest'
demands:
- MSBuild
- Xamarin.Android
- JDK
variables:
buildConfiguration: 'Release'
outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '**/*.sln'
- task: XamarinAndroid#1
inputs:
projectFile: '**/*droid*.csproj'
outputDirectory: '$(outputDirectory)'
configuration: '$(buildConfiguration)'
the fixed pipeline (yes the error was in the pipeline)
# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/xamarin
trigger:
- master
pool:
vmImage: 'windows-latest'
demands:
- MSBuild
- Xamarin.Android
- JDK
variables:
buildConfiguration: 'Release'
outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '**/*.sln'
- task: XamarinAndroid#1
inputs:
projectFile: 'XamarinFormsTry/XamarinFormsTry.Android/XamarinFormsTry.Android.csproj'
outputDirectory: '$(outputDirectory)'
configuration: '$(buildConfiguration)'
So its not that it didn't find the AndroidManifest file
it didnt find the right proj file.
changing the projectFile: '**/*droid*.csproj' to projectFile: 'XamarinFormsTry/XamarinFormsTry.Android/XamarinFormsTry.Android.csproj'
works. The right proj file is found and the proj builds successfully.
the error and the logs are a bit misleading in this case I guess
Had the same error for .NET MAUI and I figured out that the project ID was wrong in .csproj
Related
We have set up a Project in Visual Studio where we are using NuGet Packages references. For one of the NuGet Packages we are setting the GeneratePathProperty to true, so that we can copy the files from the NuGet package location to the Output bin folder of our Project
He have configured the .csproj file as below:
<PackageReference Include="ilmerge" GeneratePathProperty="true">
<Version>3.0.29</Version>
</PackageReference>
<None Include="$(Pkgilmerge)\tools\net452\ILMerge.exe">
<Link>ILMerge.exe</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="$(Pkgilmerge)\tools\net452\System.Compiler.dll">
<Link>System.Compiler.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
This works perfectly fine locally (using Visual Studio 2019) - project compiles and files are copied to the bin folder, however in our Build Pipeline using the windows-2019 hosted agent (that should also have VS 2019 as per the documentation https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md) this fails during the Build Task:
[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4601,5): Error MSB3030: Could not copy the file 'd:\tools\net452\ILMerge.exe' because it was not found.
[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4601,5): Error MSB3030: Could not copy the file 'd:\tools\net452\System.Compiler.dll' because it was not found.
The Build Definition has following tasks
steps:
- task: NuGetToolInstaller#0
- task: NuGetCommand#2
displayName: 'Restore Nugets'
inputs:
restoreSolution: '$(solutions)'
vstsFeed: 'Project-Packages'
- task: VSBuild#1
inputs:
solution: '$(solutions)'
platform: 'Any CPU'
configuration: 'Release'
logProjectEvents: false
- task: PublishBuildArtifacts#1
inputs:
pathtoPublish: '$(Build.StagingDirectory)'
artifactName: $(pluginName)
condition: always()
Any ideas what could be the issue or what we need to change in order for the build in Azure DevOps to work?
Later Edit: I added some logging
<Target Name="¨ReMerge" AfterTargets="ILRepacker" >
<Message Text="Remerging Assemblies using ILMerge from $(Pkgilmerge) and setting AssemblyVersion = 2.0.0.0" Importance="High" />
<Exec Command="dir $(Pkgilmerge)"></Exec>
<Exec Command="$(Pkgilmerge)\tools\net452\ILMerge.exe /ver:2.0.0.0 /out:$(TargetDir)$(TargetName)Merged.dll /keyfile:$(ProjectDir)Zurich.Zkp.Key.snk $(TargetDir)$(TargetName)MergedTemp.dll"></Exec>
</Target>
And it seems that in AzureDevops the $(Pkgilmerge) is empty
Thank you
The above error was caused by an old version(4.x) Nuget being used to restore your solution.
You need to specify the Nuget version to the newest for your NuGetToolInstaller task, if unspecified, a version will be chosen automatically.
Check below example to specify NuGetToolInstaller task to use 5.4.x version of Nuget.
- task: NuGetToolInstaller#0
inputs:
versionSpec: 5.4.x
I'm trying to create a basic build pipeline in Azure DevOps which builds a Visual Studio solution that includes .NET Core / .NET Standard projects and a Xamarin.Android project. The solution builds locally in VS 2019 with no issues, but always fails on the build agent with these build errors:
Error APT2260: resource style/Theme.AppCompat.Light.Dialog (aka com.companyname.obrien.connect.forms:style/Theme.AppCompat.Light.Dialog) not found.
Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(4,0): Error APT2260: style attribute 'attr/colorAccent (aka com.companyname.obrien.connect.forms:attr/colorAccent)' not found.
Error APT2260: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.companyname.obrien.connect.forms:style/Theme.AppCompat.Light.DarkActionBar) not found.
Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(2,0): Error APT2260: style attribute 'attr/windowNoTitle (aka com.companyname.obrien.connect.forms:attr/windowNoTitle)' not found.
Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(2,0): Error APT2260: style attribute 'attr/windowActionBar (aka com.companyname.obrien.connect.forms:attr/windowActionBar)' not found.
Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(2,0): Error APT2260: style attribute 'attr/colorPrimary (aka com.companyname.obrien.connect.forms:attr/colorPrimary)' not found.
Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(2,0): Error APT2260: style attribute 'attr/colorPrimaryDark (aka com.companyname.obrien.connect.forms:attr/colorPrimaryDark)' not found.
Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(3,0): Error APT2260: style attribute 'attr/colorAccent (aka com.companyname.obrien.connect.forms:attr/colorAccent)' not found.
Source\Obrien.Connect.Forms.Android\Resources\values\styles.xml(4,0): Error APT2260: style attribute 'attr/windowActionModeOverlay (aka com.companyname.obrien.connect.forms:attr/windowActionModeOverlay)' not found.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(155,3): Error APT2260: resource style/TextAppearance.AppCompat.Button (aka com.companyname.obrien.connect.forms:style/TextAppearance.AppCompat.Button) not foun
This is the YAML for the pipeline:
trigger:
- develop
- feature/*
pool:
vmImage: 'windows-2019'
variables:
- group: 'ci-build'
steps:
- task: NuGetToolInstaller#1
displayName: 'Install NuGet 5.4.0'
inputs:
versionSpec: '5.4.0'
- task: DotNetCoreCLI#2
displayName: 'Restore .NET Packages'
inputs:
command: restore
projects: '**/OBrien.Connect.Forms*/*.csproj'
verbosityRestore: minimal
- task: NuGetCommand#2
displayName: 'Restore Android Packages'
inputs:
command: 'restore'
restoreSolution: '**/OBrien.Connect.Forms.sln'
- task: VSBuild#1
displayName: 'Build Solution'
inputs:
solution: '**/$(solutionName)'
vsVersion: '16.0'
configuration: '$(buildConfiguration)'
I needed to use dotnet restore on the projects in the solution first, so that I could build them in the subsequent VSBuild task, that works fine. However, this doesn't restore any packages needed by the Xamarin.Android project as that is based on Mono and is ignored by the first restore.
That's why I added the second NuGet restore on the entire solution, but this never does anything - no errors, just this output:
##[section]Starting: Restore Android Packages
==============================================================================
Task : NuGet
Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Azure Artifacts and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
Version : 2.161.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/nuget
==============================================================================
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
[command]C:\windows\system32\chcp.com 65001
Active code page: 65001
Detected NuGet version 5.4.0.6315 / 5.4.0+d790b66be476cd901a56bd46ada037162097ee21.d790b66be476cd901a56bd46ada037162097ee21
SYSTEMVSSCONNECTION exists true
Saving NuGet.config to a temporary config file.
[command]C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://api.nuget.org/v3/index.json -ConfigFile D:\a\1\Nuget\tempNuGet_552.config
Package source with Name: NuGetOrg added successfully.
##[section]Finishing: Restore Android Packages
I've tried using the XamarinAndroid#1 build task instead of building the whole solution, but it has exactly the same build errors.
I found a good solution from a colleague who had exactly the same problem, which is to trigger the Restore target from the VSBuild task, instead of doing a NuGet restore / dotnet restore, here's the YAML:
- task: VSBuild#1
displayName: 'Restore Packages'
inputs:
solution: '**/$(solutionName)'
configuration: '$(buildConfiguration)'
vsVersion: '16.0'
msbuildArgs: '/t:Restore'
This works perfectly for building the entire solution.
A Xamarain project was created and a Devops (VSTS) pipeline was created to build and publish the project to a private nuget feed. Everything builds great, but the step that would Pack the nuget package fails.
1) My first attempt was to use the "Macos-latest" to do an msbuild#1 on the solution. The Nuget installer uses a nuspec file to do the packing. An error show's up in the packing step
2) I then tried to do a VSBuild#1, followed by a DotNetCoreClI#2 without success.
3) I also attempted to split the 3 projects (iOS, Android, UWP) into 3 separated jobs but they failed in the packing step too.
4) I tried various techniques in packing, nuspec files, the csproj file without success.
My YAML file looks like this:
'
- task: NuGetToolInstaller#1
displayName: 'Install nuget.exe 4.4.1'
inputs:
versionSpec: 4.4.1'
- task: NuGetCommand#2
displayName: "restore the ble solution"
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: '$(packageFeedName)'
- task: MSBuild#1
displayName: 'Build BLE solution'
inputs:
solution: "**/*.sln"
configuration: '$(buildConfiguration)'
msbuildArguments: '/p:OutputPath=$(outputDirectory) /p:JavaSdkDirectory="$(JAVA_HOME)/"'
- task: NuGetCommand#2
displayName: "pack nuget"
inputs:
command: pack
packagesToPack: './myproject.nuspec'
packDestination: '$(Build.ArtifactStagingDirectory)'
versioningScheme: byEnvVar
versionEnvVar: 'nugetVersion'
includeSymbols: true
'
It always comes down to the same pathing problem with I use a nuspec file.
Attempting to build package from 'BLE.nuspec'.
[error]The nuget command failed with exit code(1) and error(Could not find a part of the path /Users/vsts/agent/2.155.1/work/1/s/Plugin.BLE/bin/Release/netstandard2.0.
System.IO.DirectoryNotFoundException: Could not find a part of the path /Users/vsts/agent/2.155.1/work/1/s/Plugin.BLE/bin/Release/netstandard2.0.
When I use a **/*.csproj for the pack, I get:
Build FAILED.
d:\a\1\s\Plugin.BLE.Android\Plugin.BLE.Android.csproj" (pack target) (1:2) ->d:\a\1\s\Plugin.BLE.Android\Plugin.BLE.Android.csproj(94,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.2.105\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found.
Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Is it possible to publish a Xamarin project to a private nuget package feed in VSTS (DevOps)
The answer is yes. It depends on how many packages you want to generate.
If you want to create one nuget package for 3 projects (iOS, Android, UWP), you should use the .nuspec file.
The path problem is because you are not set the correct path in the .nuspec file. The .nuspec file should be set at the folder that's one level below where the .sln file is. The path to the dll is the relative path where the .nupsec file is stored.
So, the path should be like:
<files>
<!-- Cross-platform reference assemblies -->
<file src="XamarinDemo\bin\Release\XamarinDemo.dll" target="lib\netstandard2.0\XamarinDemo.dll" />
<file src="XamarinDemo\bin\Release\XamarinDemo.xml" target="lib\netstandard2.0\XamarinDemo.xml" />
<!-- iOS reference assemblies -->
<file src="XamarinDemo.iOS\bin\Release\XamarinDemo.dll" target="lib\Xamarin.iOS10\XamarinDemo.dll" />
<file src="XamarinDemo.iOS\bin\Release\XamarinDemo.xml" target="lib\Xamarin.iOS10\XamarinDemo.xml" />
<!-- Android reference assemblies -->
<file src="XamarinDemo.Android\bin\Release\XamarinDemo.dll" target="lib\MonoAndroid10\XamarinDemo.dll" />
<file src="XamarinDemo.Android\bin\Release\XamarinDemo.xml" target="lib\MonoAndroid10\XamarinDemo.xml" />
<!-- UWP reference assemblies -->
<file src="XamarinDemo.UWP\bin\Release\XamarinDemo.dll" target="lib\UAP10\XamarinDemo.dll" />
<file src="XamarinDemo.UWP\bin\Release\XamarinDemo.xml" target="lib\UAP10\XamarinDemo.xml" />
</files>
Check the document Create packages for Xamarin with Visual Studio 2015 for some details.
If you want to create three nuget package for each platform, you can use the a **/*.csproj for the pack.
The reason for your issue is that you need install the .NET core SDK before you build the project/solution:
- task: UseDotNet#2
displayName: 'Use .Net Core sdk 2.2.105'
inputs:
version: 2.2.105
Hope this helps.
So, my problem wasn't in my nuspec file; the real problem comes down to using the vmImage : "macos-latest", which is required if you want to build an iOS project (iOS won't build under the agents 2019, or 2017, and you must use MSBuild (not VSBuild)
The macos-latest image has several issues (which I'll refer to as the iOS agent)
The nuspec package for System.Threading.Task.Extensions (STTE) isn't included when you bring in another nuget package that has a dependency on it. If the package is in the 'Standard .net 2.0 project", then the STTE package must be included in the standard project and the ios project; this only occurs in the ios agent.
The variable I used for the solution path $(solution) did not expand to myproj.sln; the logged showed the path as /$($solution) and the project did not build, no warning or errors that zero projects were built; the problem did not occur in any other agent type that I tested.
The ios agent's Xamarin sdk is woefully out of date and has to be set.
yaml required:
variables:
mono: 5_18_1
xamarinSDK: 12_8_0_2
- task: Bash#3
displayName: "Set xamarinSDK to version $(mono)"
inputs:
targetType: 'inline'
script: /bin/bash -c "sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh $(mono)"
The technique used to figure this out was to split a Xamarin project into 4 separate projects and publish them as separate projects:
.Net Standard 2.0
UWP
Android
iOS
Every project but the iOS one worked using a VSBuild and the 2019 agent; it was then a process of elimination on the ios agent.
I'm trying to get into using Azure Devops Pipelines, and my first pet project is a simple .NET command line app I'm trying to get to be built.
I picked the "VS Build .NET Desktop" task template, and the build per se works fine - the bits are compiled without trouble
YAML:
- task: VSBuild#1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
Log:
##[section]Starting: VSBuild
==============================================================================
Task : Visual Studio build
Description : Build with MSBuild and set the Visual Studio version property
Version : 1.151.2
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/visual-studio-build
==============================================================================
##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" "d:\a\1\s\AzureDevopsTaskCreator.sln"
...(lots of lines omitted)
CopyFilesToOutputDirectory:
Copying file from "d:\a\1\s\obj\Release\AZTaskCreator.exe" to "d:\a\1\s\bin\Release\AZTaskCreator.exe".
AZTaskCreator -> d:\a\1\s\bin\Release\AZTaskCreator.exe
Copying file from "d:\a\1\s\obj\Release\AZTaskCreator.pdb" to "d:\a\1\s\bin\Release\AZTaskCreator.pdb".
But now I wanted to somehow publish the output from this build so I could download it (or deploy it somewhere). But I've been struggling with getting these things hooked up.
So I tried to first zip the build output into an archive (which could then be published):
YAML
- task: ArchiveFiles#2
inputs:
rootFolderOrFile: '$(Build.BinariesDirectory)'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/AZCreateTasks$(Build.BuildId).zip'
replaceExistingArchive: true
verbose: true
Log:
##[section]Starting: ArchiveFiles
##[command]d:\a\_tasks\ArchiveFiles_d8b84976-e99a-4b86-b885-4849694435b0\2.151.2\7zip\7z.exe a -tzip -bb3 d:\a\1\a\AZCreateTasks8.zip #d:\a\_temp\yat6561e8redmiomp7bbuik9
My problem is: HOW can I tell the "Archive Files" step to use the output directory of the previous build? I was assuming that the default $(Build.BinariesDirectory) would do that - but obviously, it doesn't:
Output from VS Build goes to the d:\a\1\s\bin\Release\ directory
Archive files step zips up files in d:\a\_temp\yat6561e8redmiomp7bbuik9 directory
How can I "connect" these two steps so that the "Archive Files" step actually respects and uses the output directory of the VS Build step??
I'm having a terribly hard time finding any useful documentation on what kind of "system pre-defined" magic variables are in play here, and how to influence these .....
According to the log, the build output is in d:\a\1\s\... the s folder it the sources directory, to access this folder there is pre-defined varaible: Build.SourcesDirectory.
So instead of using $(Build.BinariesDirectory) use the above variable:
rootFolderOrFile: '$(Build.SourcesDirectory)'
But now you will get a zip with the sources files including the dll's, so consider to append the path until the folder/s you want.
For example:
rootFolderOrFile: '$(Build.SourcesDirectory)/obj/Release'
I have a project that pulls from both public and private NuGet repositories. This works. But what doesn't seem to work is that the build on CI fails because of Microsoft.Bcl.Build, which should have gotten downloaded from the Nuget Restore Step
trigger:
- master
pool:
vmImage: 'windows-2019'
demands:
- msbuild
- visualstudio
- VSTest
- DotNetFramework
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
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.solution)'
feedsToUse: config
nugetConfigPath: .nuget/NuGet.Config
- task: VSBuild#1
displayName: 'Run Build on solution.'
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)" /p:BclBuildImported=Ignore'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
logFileVerbosity: 'diagnostic'
In the sample above, I have tried both using and removing /p:BclBuildImported=Ignore'.
The library I am using has BCL ref in it, so I cannot remove that dependancy. And this code falls apart when I switch it to core.
Everything does work when I build it in Visual Studio 2019 Ent, and Pro, just refuses to build on MS DevOps, on the Hosted 2017 platform.
Tried fixes, and comment/discussion follow-up since initial post:
Multiple pools have been tried, all failing.
This does build in VS 2017 & 2019 on pro and enterprise on various desktops.
The error is This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets. even though all packages are being installed, and the Nuget download shows no errors or skips.
The following fixes have not worked:
How to bypass Microsoft.Bcl.Build warning
What does the Microsoft.Bcl.Build NuGet package do?
Have you tried MS DevOps, on the Hosted 2019 platform, instead of using a 2017 Host?
Hosted Windows 2019 with VS2019
I ended up removing all BCL dependencies and built a lot of workarounds. This was no minor change. Unfortunately, as this is 2 years ago, I don't have the details of what I did back then.