Skip to content

Commit

Permalink
Update azure-pipelines.yml for Azure Pipelines (#102)
Browse files Browse the repository at this point in the history
* Update azure-pipelines.yml for Azure Pipelines
* fix warings, update pipeline
* added scripts to change to use nuget
* fix variables
* fix sh version
* fix sh script
* fix csproj

Co-authored-by: AntonioSeric <antonio@littlecode.com>
  • Loading branch information
anTONIos and AntonioSeric authored Jul 4, 2021
1 parent 542c5d2 commit 19e8009
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 51 deletions.
4 changes: 4 additions & 0 deletions .azure-devops/msbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
echo $MONO_OPTIONS
echo $@
mono '/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/msbuild.dll' "$@"
12 changes: 12 additions & 0 deletions .azure-devops/use-nuget.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$nugetVersion = $Env:NUGETVERSION
echo "Nuget Version = "$nugetVersion

((Get-Content src/Calendar.Plugin.Sample/SampleApp/SampleApp.csproj) -replace '<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj"', "<PackageReference Include=""Xamarin.Plugin.Calendar"" Version=""$($nugetVersion)""") | Out-File -encoding ASCII src/Calendar.Plugin.Sample/SampleApp/SampleApp.csproj

# (Get-Content src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj) | Where-Object {$_ -notmatch '81e938f4-a11c-4726-a13f-0d7ecc84ca66'} | Out-File -encoding ASCII src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
# (Get-Content src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj) | Where-Object {$_ -notmatch '<Name>CalendarPlugin'} | Out-File -encoding ASCII src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
(Get-Content src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj -Raw) -replace "(?sm)<ProjectReference Include=""..\\..\\Calendar.Plugin\\CalendarPlugin.csproj"">.*?</ProjectReference>", "<PackageReference Include=""Xamarin.Plugin.Calendar"" Version=""$($nugetVersion)"" />" | Out-File -encoding ASCII src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj

# (Get-Content src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj) | Where-Object {$_ -notmatch '81e938f4-a11c-4726-a13f-0d7ecc84ca66'} | Out-File -encoding ASCII src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
# (Get-Content src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj) | Where-Object {$_ -notmatch '<Name>CalendarPlugin'} | Out-File -encoding ASCII src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
(Get-Content src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj -Raw) -replace "(?sm)<ProjectReference Include=""..\\..\\Calendar.Plugin\\CalendarPlugin.csproj"">.*?</ProjectReference>", "<PackageReference Include=""Xamarin.Plugin.Calendar"" Version=""$($nugetVersion)"" />" | Out-File -encoding ASCII src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
19 changes: 19 additions & 0 deletions .azure-devops/use-nuget.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

echo "Nuget Version = "$NUGETVERSION

sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj"/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$NUGETVERSION'"/g' src/Calendar.Plugin.Sample/SampleApp/SampleApp.csproj

sed -i .bak -e '/81e938f4-a11c-4726-a13f-0d7ecc84ca66/d' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -i .bak -e '/<Name>CalendarPlugin/d' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -E -i .bak -e '/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/{N;s/\n.*//;}' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$NUGETVERSION'" \/>/g' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj

sed -i .bak -e '/81e938f4-a11c-4726-a13f-0d7ecc84ca66/d' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -i .bak -e '/<Name>CalendarPlugin/d' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -E -i .bak -e '/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/{N;s/\n.*//;}' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$NUGETVERSION'" \/>/g' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj

## Debug
#cat src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
#cat src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
81 changes: 36 additions & 45 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ variables:
buildPlatform: 'AnyCPU'
buildConfiguration: 'Release'
nugetVersion: '1.4.$(Build.BuildId)'
MonoVersion: 6_12_0
monoVersion: 6_12_7
dotentVersion: 5.x

jobs:
- job: 'Nuget'
displayName: 'Build Nuget'
pool:
vmImage: 'windows-latest'
steps:
- task: NuGetToolInstaller@1
- task: UseDotNet@2
displayName: 'Use dotnet sdk 3.x'
displayName: 'Use dotnet sdk $(dotentVersion)'
inputs:
version: 3.x
version: $(dotentVersion)

- task: NuGetCommand@2
displayName: 'Nuget restore solution'
Expand Down Expand Up @@ -49,14 +51,22 @@ jobs:
ArtifactName: nupkg

- job: 'iOSSampleApp'
displayName: 'Build iOS Sample App'
dependsOn:
- Nuget
pool:
vmImage: 'macOS-latest'
demands:
- msbuild
- visualstudio
steps:
- task: NuGetToolInstaller@1
- task: UseDotNet@2
displayName: 'Use dotnet sdk $(dotentVersion)'
inputs:
version: $(dotentVersion)

- script: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh $MonoVersion
- script: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh $monoVersion
displayName: 'Selecting the Xamarin SDK version'

- task: DownloadBuildArtifacts@0
Expand All @@ -68,50 +78,41 @@ jobs:
artifactName: 'nupkg'

- task: Bash@3
displayName: "Replace project ref with nuget reference"
inputs:
filePath: '.azure-devops/use-nuget.sh'

- task: Bash@3
displayName: "Restore nuget packages"
inputs:
targetType: 'inline'
script: |
sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj"/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$(nugetVersion)'"/g' src/Calendar.Plugin.Sample/SampleApp/SampleApp.csproj
sed -i .bak -e '/81e938f4-a11c-4726-a13f-0d7ecc84ca66/d' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -i .bak -e '/<Name>CalendarPlugin/d' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -E -i .bak -e '/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/{N;s/\n.*//;}' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$(nugetVersion)'" \/>/g' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -i .bak -e '/81e938f4-a11c-4726-a13f-0d7ecc84ca66/d' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -i .bak -e '/<Name>CalendarPlugin/d' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -E -i .bak -e '/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/{N;s/\n.*//;}' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$(nugetVersion)'" \/>/g' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
cat src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
cat src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
nuget restore src/Calendar.Plugin.Sample/SampleApp/SampleApp.csproj -NonInteractive -Source $(build.binariesDirectory)/nuget/nupkg/ -Source https://api.nuget.org/v3/index.json
nuget restore src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj -NonInteractive -Source $(build.binariesDirectory)/nuget/nupkg/ -Source https://api.nuget.org/v3/index.json
chmod 755 $(Build.Repository.LocalPath)/.azure-devops/msbuild.sh
- task: XamariniOS@2
continueOnError: true
inputs:
buildToolLocation: '$(Build.Repository.LocalPath)/.azure-devops/msbuild.sh'
solutionFile: '**/SampleApp.iOS.csproj'
configuration: '$(buildConfiguration)'
packageApp: false
runNugetRestore: false
buildForSimulator: true

- job: 'AndroidSampleApp'
displayName: 'Build Android Sample App'
dependsOn:
- Nuget
pool:
vmImage: 'macOS-latest'
vmImage: 'windows-latest'
steps:
- task: NuGetToolInstaller@1
- task: UseDotNet@2
displayName: 'Use dotnet sdk 3.x'
displayName: 'Use dotnet sdk $(dotentVersion)'
inputs:
version: 3.x

- script: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh $MonoVersion
displayName: 'Selecting the Xamarin SDK version'
version: $(dotentVersion)

- task: DownloadBuildArtifacts@0
displayName: "Download PackNugetPackage artifacts"
Expand All @@ -121,27 +122,17 @@ jobs:
downloadPath: '$(build.binariesDirectory)/nuget/'
artifactName: 'nupkg'

- task: Bash@3
- task: PowerShell@2
displayName: "Replace project ref with nuget reference"
inputs:
filePath: '.azure-devops\use-nuget.ps1'

- task: CmdLine@2
displayName: "Restore nuget packages"
inputs:
targetType: 'inline'
script: |
sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj"/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$(nugetVersion)'"/g' src/Calendar.Plugin.Sample/SampleApp/SampleApp.csproj
sed -i .bak -e '/81e938f4-a11c-4726-a13f-0d7ecc84ca66/d' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -i .bak -e '/<Name>CalendarPlugin/d' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -E -i .bak -e '/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/{N;s/\n.*//;}' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$(nugetVersion)'" \/>/g' src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
sed -i .bak -e '/81e938f4-a11c-4726-a13f-0d7ecc84ca66/d' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -i .bak -e '/<Name>CalendarPlugin/d' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -E -i .bak -e '/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/{N;s/\n.*//;}' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
sed -E -i .bak -e 's/<ProjectReference Include="..\\..\\Calendar.Plugin\\CalendarPlugin.csproj">/<PackageReference Include="Xamarin.Plugin.Calendar" Version="'$(nugetVersion)'" \/>/g' src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
cat src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj
cat src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
nuget restore src/Calendar.Plugin.Sample/SampleApp/SampleApp.csproj -NonInteractive -Source $(build.binariesDirectory)/nuget/nupkg/ -Source https://api.nuget.org/v3/index.json
nuget restore src/Calendar.Plugin.Sample/SampleApp.Android/SampleApp.Android.csproj -NonInteractive -Source $(build.binariesDirectory)/nuget/nupkg/ -Source https://api.nuget.org/v3/index.json
nuget restore src\Calendar.Plugin.Sample\SampleApp\SampleApp.csproj -NonInteractive -Source $(build.binariesDirectory)\nuget\nupkg\ -Source https://api.nuget.org/v3/index.json
nuget restore src\Calendar.Plugin.Sample\SampleApp.Android\SampleApp.Android.csproj -NonInteractive -Source $(build.binariesDirectory)\nuget\nupkg\ -Source https://api.nuget.org/v3/index.json
- task: XamarinAndroid@1
displayName: 'Build Xamarin.Android project SampleApp.Android.csproj'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.0" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.V4" Version="1.0.0.7" />
<PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.8" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.3" />
<PackageReference Include="Xamarin.AndroidX.MediaRouter" Version="1.2.4" />
<PackageReference Include="Xamarin.AndroidX.Legacy.Support.Core.Utils" Version="1.0.0.7" />
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.3.0.5" />
<PackageReference Include="Xamarin.Forms">
Expand Down
3 changes: 3 additions & 0 deletions src/Calendar.Plugin.Sample/SampleApp.iOS/SampleApp.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
<AppExtensionDebugBundleId />
</PropertyGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
Expand Down
5 changes: 3 additions & 2 deletions src/Calendar.Plugin.Sample/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<ProduceAssemblyReference>true</ProduceAssemblyReference>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>pdbonly</DebugType>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
2 changes: 1 addition & 1 deletion src/Calendar.Plugin/CalendarPlugin.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras/3.0.23">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;MonoAndroid10.0;Xamarin.iOS10</TargetFrameworks>
<TargetFrameworks>netstandard2.1;MonoAndroid10.0;Xamarin.iOS10</TargetFrameworks>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<PackageId>Xamarin.Plugin.Calendar</PackageId>
<PackageTags>events calendar, calendar, xamarin forms, custom calendar</PackageTags>
Expand Down
6 changes: 4 additions & 2 deletions src/Calendar.Plugin/Shared/Controls/Calendar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ public bool AnimateCalendar
public static readonly BindableProperty SelectedDateProperty =
BindableProperty.Create(nameof(SelectedDate), typeof(DateTime?), typeof(Calendar), null, BindingMode.TwoWay, propertyChanged: OnSelectedDateChanged);

protected internal static void OnSelectedDateChanged(BindableObject bindable, object oldValue, object newValue)
private static void OnSelectedDateChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (Calendar)bindable;
var dateToSet = (DateTime?)newValue;
Expand Down Expand Up @@ -1022,7 +1022,9 @@ private static void OnMonthYearChanged(BindableObject bindable, object oldValue,
}
}

/// <summary> Method that is called when a bound property is changed. </summary>
/// <summary>
/// Method that is called when a bound property is changed.
/// </summary>
/// <param name="propertyName">The name of the bound property that changed.</param>
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Calendar.Plugin/Shared/Controls/RangeSelectionCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public RangeSelectionCalendar() : base()
_selectionEngine = monthDaysView.CurrentSelectionEngine as RangedSelectionEngine;
}

/// <summary>
/// Method that is called when a bound property is changed.
/// </summary>
/// <param name="propertyName">The name of the bound property that changed.</param>
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
base.OnPropertyChanged(propertyName);
Expand Down

0 comments on commit 19e8009

Please sign in to comment.