For my project (Mobile iOS application, based on Xamarin) I have set up Azure Pipelines build process.
I would like to automatically increase and set the ipa-file version for every build.
Upon searching the Internet I have found an article that advises to add the following code to the ios project .csproj file:
<Target Name="BeforeBuild" Condition=" $(SetVersion) == true ">
<GetAssemblyIdentity AssemblyFiles="$(AssemblyPath)">
<Output TaskParameter="Assemblies" ItemName="AssemblyInfo" />
</GetAssemblyIdentity>
<PropertyGroup>
<VersionNumber>$([System.Text.RegularExpressions.Regex]::Match(%(AssemblyInfo.Version), `[^.][^.]*.[^.]*.[^.]*`))</VersionNumber>
</PropertyGroup>
<XmlPoke XmlInputPath="Resources/Info.plist" Query="//dict/key[. = 'CFBundleVersion']/following-sibling::string[1]" Value="$(BuildNumber)" />
<XmlPoke XmlInputPath="Resources/Info.plist" Query="//dict/key[. = 'CFBundleShortVersionString']/following-sibling::string[1]" Value="$(VersionNumber)" />
I set version number manually and as I don't need the assembly version number I have added this simplified code to my iosProject.csproj file:
<Target Name="BeforeBuild" Condition=" $(SetVersion) == true ">
<XmlPoke XmlInputPath="Info.plist" Query="//dict/key[. = 'CFBundleVersion']/following-sibling::string[1]" Value="$(BuildNumber)" />
<XmlPoke XmlInputPath="Info.plist" Query="//dict/key[. = 'CFBundleShortVersionString']/following-sibling::string[1]" Value="$(VersionNumber).$(BuildNumber)" />
</Target>
In my azure-pipelines.yml file I have the following command line with hardcoded values (just for debugging purposes) for msbuild call:
variables:
mobileProjectMSbuildArgumentsForIOS: "/p:SetVersion=true /p:VersionNumber=1.0 /p:BuildNumber=34 /bl:$(Build.ArtifactStagingDirectory)/build_iOS.binlog"
As you can see, SetVersion is true, VersionNumber is 1.0 and BuildNumber is 44.
Tasks to make the build and generate binary log are as follows:
- task: XamariniOS#2
inputs:
solutionFile: '**/*iOS.csproj'
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
signingProvisioningProfileID: '$(APPLE_PROV_PROFILE_UUID)'
configuration: '$(buildConfiguration)'
msbuildArguments: "$(mobileProjectMSbuildArgumentsForIOS)"
outputDirectory: "$(outputDirectory)"
packageApp: true
args: /p:IpaPackageDir="$(outputDirectory)"
- task: PublishBuildArtifacts#1
displayName: 'Publish binary log'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Binary log'
publishLocation: 'Container'
condition: succeededOrFailed()
But when the project has been built using pipelines, the build is green, but:
The version of the ipa-file has not set to the expected 1.0.34, it has old value, that was set manually in .plist file in the project.
binary log is not being generated. upon running task to publish the binary log I get the message:
##[warning]Directory '/Users/runner/work/1/a' is empty. Nothing will be added to build artifact 'Binary log'.
My questions:
Why XmlPoke does not work for ios.csproj file, even SetVersion is set to true?
Why binary log is not being generated?
Any ideas are welcome.
Thank you.
I found you had mistakes in XamariniOS#2 task. Fields msbuildArguments And outputDirectory are fields for Xamarin.Android task. They donot exist for Xamarin.iOS task
So you can try moving /p:IpaPackageDir="$(outputDirectory)" And outputDirectory: "$(outputDirectory)" to your mobileProjectMSbuildArgumentsForIOS variable.
variables:
mobileProjectMSbuildArgumentsForIOS: "/p:OutputPath=$(outputDirectory) /p:IpaPackageDir="$(outputDirectory)" /p:SetVersion=true /p:VersionNumber=1.0 /p:BuildNumber=34 /bl:$(Build.ArtifactStagingDirectory)/build_iOS.binlog"
Then assign the msbuildArguments to args fields: args: "$(mobileProjectMSbuildArgumentsForIOS)"
See below changed the XamariniOS#2 task:
- task: XamariniOS#2
inputs:
solutionFile: '**/*iOS.csproj'
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
signingProvisioningProfileID: '$(APPLE_PROV_PROFILE_UUID)'
configuration: '$(buildConfiguration)'
args: "$(mobileProjectMSbuildArgumentsForIOS)"
packageApp: true
Related
I have a step in my build pipeline that looks like this:
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '${{ parameters.configuration }}'
The artifacts end up being put into a .zip archive, and all is well, and I can extract that and copy it to the destination of my choice. But I'm wondering what, if anything, is done with information in the .pubxml file, which looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Texas</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>\\subdomain.webserver.com\qa\WebServices\APILocation\Texas</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
</Project>
Later in my build pipeline, I'd like to copy the artifacts to the location specified in the publishUrl node of that .pubxml file. How can I access that information from within the pipeline?
I'd like to copy the artifacts to the location specified in the publishUrl node of that .pubxml file. How can I access that information from within the pipeline?
You could deploy the pipeline with the .pubxml file:
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:PublishProfile=$(Build.SourcesDirectory)\xxx\Properties\PublishProfiles\YourProfile.pubxml'
platform: '$(buildPlatform)'
configuration: '${{ parameters.configuration }}'
And if you have any other argument want to override the it in the build arguments,like:
/p:publishUrl=$(Build.ArtifactStagingDirectory)
I am tasks with adding steps to a pipeline that will create and deploy a clickonce application from an application. Here is what I have so far for my yml file:
trigger:
- ReleaseCandidate
pool:
name: 'PoolTest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'config'
nugetConfigPath: 'CTVdbNG.Master/NuGet.config'
- task: VSBuild#1
inputs:
solution: '$(solution)'
msbuildArgs: '/target:publish /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: VSTest#2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
I only build and test...but how do I create a clickonce package?
create a clickonce package on local machine from Azure pipeline?
There is no directly way or argument to generate the package for the clickonce project.
To generate the package, you could edit the project file for your client project and add the following at the bottom (right above the tag):
<PropertyGroup>
<!--Unless specified otherwise, the tools will go to HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1 to get the installpath for msdeploy.exe.-->
<MSDeployPath Condition="'$(MSDeployPath)'==''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\3#InstallPath)</MSDeployPath>
<MSDeployPath Condition="'$(MSDeployPath)'==''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\2#InstallPath)</MSDeployPath>
<MSDeployPath Condition="'$(MSDeployPath)'==''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1#InstallPath)</MSDeployPath>
<MSDeployExe Condition=" '$(MSDeployExe)'=='' ">$(MSDeployPath)msdeploy.exe</MSDeployExe>
</PropertyGroup>
<Target Name="CreateWebDeployPackage" AfterTargets="Publish" DependsOnTargets="Publish">
<!--
%msdeploy%
-verb:sync
-source:contentPath="C:\Temp\_NET\WebPackageWithClickOnce\WebPackageWithClickOnce\bin\Debug\app.publish"
-dest:package="C:\Temp\_NET\WebPackageWithClickOnce\WebPackageWithClickOnce\bin\Debug\co-pkg.zip"
-->
<PropertyGroup>
<Cmd>"$(MSDeployExe)" -verb:sync -source:contentPath="$(MSBuildProjectDirectory)\$(PublishDir)" -dest:package="$(OutDir)cotest.zip"</Cmd>
</PropertyGroup>
<Message Text="Creating web deploy package with command: $(Cmd)" />
<Exec Command="$(Cmd)" />
</Target>
It will generate the cotest.zip under the path bin\Debug\cotest.zip.
Source reference: Create a clickonce webdeploy package
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
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 deploying a WPS application to multiple different shared network drives. Each application will have to target a different Database. On top of this since I'm using clickOnce deployment each location will need its own PublishUrl and InstallUrl.
I currently have a single pipeline that can deploy to each location (eventually I'll break it up into multiple pipelines).
The problems are that when it publishes it creates two folders. One MyAppName and another MyAppNameapp.publish it does not set InstallUrl, PublishUrl, UpdateUrl or $(AssemblyVersion) and (don't know if is an actual issue) sets the deploymentProvider codebase to a folder inside my local agent (used to run this pipe).
Folder:MyAppName
Contains
A published version of my application
Folder:MyAppNameapp.publish
Contains
Setup.exe
MyAppName.application
Inside File
<deploymentProvider codebase="[Folder inside my local agent]" />
Missing InstallUrl, PublishUrl, UpdateUrl
MyAppName.exe
Folder:Application Files
Contains
Folder:MyAppNameapp_$(AssemblyVersion)
Contains
A published version of my application
How to I limit MsBuild to only create MyAppNameapp.publish (but renamed to MyAppName)
This is MsBuild task being used to create these folders.
- task: MSBuild#1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '/target:Publish
/p:ApplicationVersion=$(AssemblyVersion)
/p:UpdateEnabled=true /p:UpdateMode=Foreground
/p:ProductName=TenantAnalyticsTool
/p:InstallUrl=c:\sandbox\deploytesting\siteA
/p:PublishUrl=c:\sandbox\deploytesting\siteA
/p:UpdateUrl=c:\sandbox\deploytesting\siteA
/p:OutputPath=c:\sandbox\deploytesting\siteA
/p:OutDir=c:\sandbox\deploytesting\siteA '
msbuildArchitecture: x64
I've tried:
-redirecting OutputPath and OutDir to a different location but then nothing gets created at c:\sandbox\deploytesting\siteA.
-removing both causes no folder to be created. If I remove only one (either) MSBuild doesn't copy all the files over.
Complete yaml
# 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:
- master
pool: Default
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: MSBuild#1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArchitecture: 'x64'
- task: VisualStudioTestPlatformInstaller#1
inputs:
packageFeedSelector: 'nugetOrg'
versionSelector: 'latestStable'
- task: VSTest#2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
vsTestVersion: 'toolsInstaller'
- task: MSBuild#1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '/target:Publish
/p:ApplicationVersion=$(AssemblyVersion)
/p:UpdateEnabled=true /p:UpdateMode=Foreground
/p:ProductName=TenantAnalyticsTool
/p:InstallUrl=c:\sandbox\deploytesting\siteA
/p:PublishUrl=c:\sandbox\deploytesting\siteA
/p:UpdateUrl=c:\sandbox\deploytesting\siteA
/p:OutputPath=c:\sandbox\deploytesting\siteA
/p:OutDir=c:\sandbox\deploytesting\siteA '
msbuildArchitecture: x64
New MSBuild#1 test.
- task: MSBuild#1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '/t:Publish
/p:ApplicationVersion=$(Build.BuildId)
/p:UpdateEnabled=true
/p:UpdateMode=Foreground
/p:ProductName=TenantAnalyticsTool
/p:OutputPath=c:\sandbox\deploytesting\siteC
/p:InstallUrl=c:\sandbox\deploytesting\siteC
/p:PublishUrl=c:\sandbox\deploytesting\siteC'
msbuildArchitecture: x64
Outcome: Folder structure remains unchanged
Inside of MyAppName.application
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<assemblyIdentity name="MyAppName" version="1.0.0.34" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="CBRE" asmv2:product="Tenant Tool Analytics Module" xmlns="urn:schemas-microsoft-com:asm.v1" />
<deployment install="true" co.v1:createDesktopShortcut="true">
<subscription>
<update>
<beforeApplicationStartup />
</update>
</subscription>
<deploymentProvider codebase="file://catd...[Not a location specified in the pipe].../MyAppName.application" />
</deployment>
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
<framework targetVersion="4.7.2" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>
<dependency>
<dependentAssembly dependencyType="install" codebase="Application Files\Tenant Tool Analytics Module_198\Tenant Tool Analytics Module.exe.manifest" size="8606">
<assemblyIdentity name="Tenant Tool Analytics Module.exe" version="1.0.0.34" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>R5zudfS3VXtM5dKoEFbHYoZih0Sxr8CjX33H5FgvBk8=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
</asmv1:assembly>
/t:Publish will publish to the folder defined in Property /p:OutputPath=siteA. and a subfolder publish will be created. So this example will publish to folder siteA\publish
/p:OutDir is for /t:build. It will include the files from the build result.
For your case i think you can just only use /p:OutputPath, not /p:OutDir.
As for $(AssemblyVersion) not set. It is because AssemblyVersion is not defined in your pipeline variables. Syntax $() in pipeline will look for variable defined in pipeline variables or pipeline predefined variables.
YAML that finally worked for me. Repeating the two MSBuild tasks I can publish the application to a network drive.
# 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:
- master
pool: Default
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
NewBuildID: $(BuildID)
steps:
- task: NuGetToolInstaller#1
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
- task: MSBuild#1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '
/p:UpdateEnabled=true
/p:UpdateMode=Foreground
/p:ProductName="Tenant Analytics Tool"
/p:BootstrapperEnabled=false
'
msbuildArchitecture: 'x64'
- task: MSBuild#1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '/t:Publish
/p:UpdateEnabled=true
/p:UpdateMode=Foreground
/p:ProductName="Tenant Analytics Tool"
/p:PublishDir=H:\sandbox\deploytesting\SiteA\
/p:UpdateUrl=\\CATD...[Network Location not network drive]... \sandbox\deploytesting\siteA\
/p:BootstrapperEnabled=false
'
msbuildArchitecture: x64