Skip to content

Commit

Permalink
Use new versioning scheme
Browse files Browse the repository at this point in the history
- Use a static AssemblyVersion number to fix issues with VS for Mac and strong naming with auto versions, but still auto increment AssemblyFileVersion so new builds are always considered different.
- Generate version info file during build dynamically
- Versions of the .dll now match the version currently targeted
- Use -dev instead of -alpha suffix for develop builds
- GlobalAssemblyInfo is included automatically using the common build targets
- Update versions of addins and appveyor.yml when creating new releases/builds
- Addin assemblies now use global assembly info and generated version.
  • Loading branch information
cwensley authored Sep 26, 2018
1 parent d55869c commit 08070f0
Show file tree
Hide file tree
Showing 77 changed files with 843 additions and 861 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ charset=utf-8
[**\packages.config]
indent_style = space
indent_size = 2

[*.{csproj,vbproj,proj,targets,props}]
indent_style = space
indent_size = 2
tab_size = 2
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ install:
- cinst gtksharp -y
build_script:
- set BASE=%APPVEYOR_BUILD_FOLDER%
- set BUILD_VERSION=000%APPVEYOR_BUILD_NUMBER%
- set BUILD_VERSION=2.5.0-build%BUILD_VERSION:~-4%
- set BUILD_VERSION_NUMBER=000%APPVEYOR_BUILD_NUMBER%
- set BUILD_VERSION=2.5.0-build%BUILD_VERSION_NUMBER:~-4%
- msbuild -t:Package -p:BuildVersion=%BUILD_VERSION% build\Build.proj /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /consoleloggerparameters:NoSummary
- msbuild -t:BuildAddins build\Build.proj /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /consoleloggerparameters:NoSummary
test: off
Expand Down
599 changes: 303 additions & 296 deletions build/Build.proj

Large diffs are not rendered by default.

21 changes: 0 additions & 21 deletions build/Build.props

This file was deleted.

20 changes: 10 additions & 10 deletions build/BuildMacAddin.targets
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@
<!-- this builds the Xamarin Studio addin specifically for addins.monodevelop.com -->

<PropertyGroup>
<ArtifactsDir>$(BaseDir)\artifacts</ArtifactsDir>
<AllPackagesConfig>$(MSBuildThisFileDirectory)\packages.config</AllPackagesConfig>
<NugetOutputDir>$(ArtifactsDir)\Nuget\$(Configuration)</NugetOutputDir>
<XamarinStudioAddinProject>$(SourceDir)\Addins\Eto.Addin.XamarinStudio.sln</XamarinStudioAddinProject>
<ArtifactsDir>$(BasePath)artifacts</ArtifactsDir>
<AllPackagesConfig>$(MSBuildThisFileDirectory)packages.config</AllPackagesConfig>
<NugetOutputDir>$(ArtifactsDir)Nuget\$(Configuration)</NugetOutputDir>
<XamarinStudioAddinProject>$(SourceDir)Addins\Eto.Addin.XamarinStudio.sln</XamarinStudioAddinProject>
</PropertyGroup>

<Exec Command='nuget restore -PackagesDirectory "$(MSBuildThisFileDirectory)\packages" -ConfigFile $(AllPackagesConfig)' />
<Exec Command='nuget restore -PackagesDirectory "$(MSBuildThisFileDirectory)packages" -ConfigFile $(AllPackagesConfig)' />

<ItemGroup>
<SourceNupkg Include="$(MSBuildThisFileDirectory)\packages\Eto.*\*.nupkg" />
<SourceNupkg Include="$(MSBuildThisFileDirectory)packages\Eto.*\*.nupkg" />
</ItemGroup>

<MakeDir Directories="$(NugetOutputDir)" />
<Copy SourceFiles="%(SourceNupkg.Identity)" DestinationFiles="$(NugetOutputDir)\%(Filename)%(Extension)" />
<Copy SourceFiles="%(SourceNupkg.Identity)" DestinationFiles="$(NugetOutputDir)%(Filename)%(Extension)" />

<Exec Command="$(NuGetCommand) restore $(XamarinStudioAddinProject)" />
<!--MSBuild Projects="$(XamarinStudioAddinProject)" Targets="RestorePackages" Properties="Configuration=$(Configuration)"/-->
<MSBuild Projects="$(XamarinStudioAddinProject)" Targets="Build" Properties="Configuration=$(SolutionConfiguration)"/>
</Target>
<Target Name="Clean">
<!-- clean output from previous builds -->
<Exec Command="rm -rf $(BaseDir)\artifacts" />
<Exec Command="rm -rf $(MSBuildThisFileDirectory)\packages\Eto.*" />
<Exec Command="rm -rf $(SourceDir)\Addins\packages" />
<Exec Command="rm -rf $(BasePath)artifacts" />
<Exec Command="rm -rf $(MSBuildThisFileDirectory)packages\Eto.*" />
<Exec Command="rm -rf $(SourceDir)Addins\packages" />
</Target>
</Project>
23 changes: 23 additions & 0 deletions build/Common.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)Common.props" />
<PropertyGroup>

<AssemblyVersion Condition="$(AssemblyVersion) == ''">2.5.0.0</AssemblyVersion>
<AssemblyInformationalVersion Condition="$(AssemblyInformationalVersion) == ''">2.5.0-dev</AssemblyInformationalVersion>

<XamarinMacPath>\Library\Frameworks\Xamarin.Mac.framework\Versions\Current</XamarinMacPath>
<XamarinMacLibPath>$(XamarinMacPath)\lib\mono</XamarinMacLibPath>
<ReferencePath Condition="$(ReferencePath) == '' and Exists('$(XamarinMacLibPath)')">$(XamarinMacLibPath)</ReferencePath>
<!-- Prevent VS2015 from copying files from the GAC to the output folder -->
<DoNotCopyLocalIfInGac>true</DoNotCopyLocalIfInGac>
<BaseIntermediateOutputPath>$(BasePath)artifacts\obj\$(OSPlatform)\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyVersion Condition="$(GenerateAssemblyVersion) == ''">True</GenerateAssemblyVersion>
<Deterministic Condition="$(Deterministic) == '' and $(GenerateAssemblyVersion) == 'True'">True</Deterministic>
<Deterministic Condition="$(Deterministic) == ''">False</Deterministic>
<!-- RestoreProjectStyle will be supported in VS for Mac 7.4 -->
<RestoreProjectStyle Condition="'$(RestoreProjectStyle)' == '' AND $(UsePackagesConfig) != 'True'">PackageReference</RestoreProjectStyle>
</PropertyGroup>
<Import Condition="Exists('$(BasePath)..\Eto.Common.props')" Project="$(BasePath)..\Eto.Common.props" />
</Project>
74 changes: 74 additions & 0 deletions build/Build.targets → build/Common.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,50 @@
</Code>
</Task>
</UsingTask>

<UsingTask TaskName="GenerateVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Version ParameterType="System.String" Required="true" Output="true" />
</ParameterGroup>
<Task>
<Code Type="Class" Language="cs">
<![CDATA[
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Diagnostics;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class GenerateVersion : Task
{
[Output]
public string Version { get; set; }
public override bool Execute()
{
var currentDate = DateTime.Now;
var timeSpanDays = currentDate - new DateTime(2000, 01, 01);
var timeSpanSeconds = currentDate - DateTime.Today;
var numberOfDays = (int)timeSpanDays.TotalDays;
var numberOfSeconds = (int)(timeSpanSeconds.TotalSeconds / 2);
var versionString = Version.Replace(".*", "");
var version = System.Version.Parse(versionString);
Version = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, numberOfDays, numberOfSeconds);
return true;
}
}
]]></Code>
</Task>
</UsingTask>

<Target Name="_EmbedReferencedAssemblies" Condition="$(EmbedReferences) != ''" AfterTargets="ResolveAssemblyReferences">
<PropertyGroup>
<EmbedDebugSymbols Condition="$(EmbedDebugSymbols) == ''">false</EmbedDebugSymbols>
Expand Down Expand Up @@ -88,4 +132,34 @@
<Message Text="%(Reference.Filename) - %(Reference.HintPath)" Importance="high" />
-->
</Target>

<ItemGroup Condition="$(GenerateAssemblyVersion) == 'True'">
<Compile Include="$(IntermediateOutputPath)VersionInfo.cs">
<Link>Properties\VersionInfo.cs</Link>
<Visible>false</Visible>
</Compile>
<Compile Include="$(SourceDir)Shared\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
<Visible>false</Visible>
</Compile>
</ItemGroup>

<Target Name="_WriteVersion" BeforeTargets="BeforeBuild" Condition="$(GenerateAssemblyVersion) == 'True'">
<!-- Generate auto version number so:
a) we can use deterministic builds
b) VS on Mac won't break intellisense when strong naming the assemblies
see: https://github.com/mono/monodevelop/issues/4763
-->
<GenerateVersion Version="$(AssemblyVersion)">
<Output TaskParameter="Version" PropertyName="AssemblyFileVersion" />
</GenerateVersion>

<ItemGroup>
<VersionInfo Include="[assembly: System.Reflection.AssemblyVersion(&quot;$(AssemblyVersion)&quot;)]" />
<VersionInfo Include="[assembly: System.Reflection.AssemblyFileVersion(&quot;$(AssemblyFileVersion)&quot;)]" />
<VersionInfo Include="[assembly: System.Reflection.AssemblyInformationalVersion(&quot;$(AssemblyInformationalVersion)&quot;)]" />
</ItemGroup>
<MakeDir Directories="$(IntermediateOutputPath)" />
<WriteLinesToFile File="$(IntermediateOutputPath)VersionInfo.cs" Overwrite="True" Lines="@(VersionInfo)" />
</Target>
</Project>
31 changes: 31 additions & 0 deletions build/Common.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BasePath>$(MSBuildThisFileDirectory)..\</BasePath>
<OSPlatform Condition="$(OSPlatform) == '' and '$(OS)' == 'Unix' and !Exists('/Library/Frameworks')">Linux</OSPlatform>
<OSPlatform Condition="$(OSPlatform) == '' and '$(OS)' == 'Unix' and Exists('/Library/Frameworks')">Mac</OSPlatform>
<OSPlatform Condition="$(OSPlatform) == '' and '$(OS)' != 'Unix'">Windows</OSPlatform>

<XamarinMacPath>\Library\Frameworks\Xamarin.Mac.framework\Versions\Current\</XamarinMacPath>
<XamarinMacLibPath>$(XamarinMacPath)lib\mono\</XamarinMacLibPath>
<ReferencePath Condition="$(ReferencePath) == '' and Exists('$(XamarinMacLibPath)')">$(XamarinMacLibPath)</ReferencePath>

<ArtifactsDir Condition="$(BuildOutoutDir) == ''">$(BasePath)artifacts\</ArtifactsDir>
<ArtifactsNet45Dir Condition="$(ArtifactsNet45Dir) == ''">$(ArtifactsDir)core\$(Configuration)\net45\</ArtifactsNet45Dir>
<ArtifactsNetStandard10Dir Condition="$(ArtifactsNetStandard10Dir) == ''">$(ArtifactsDir)core\$(Configuration)\netstandard1.0\</ArtifactsNetStandard10Dir>
<ArtifactsNetStandard20Dir Condition="$(ArtifactsNetStandard20Dir) == ''">$(ArtifactsDir)core\$(Configuration)\netstandard2.0\</ArtifactsNetStandard20Dir>
<ArtifactsModernDir Condition="$(ArtifactsModernDir) == ''">$(ArtifactsDir)core\$(Configuration)\modern\</ArtifactsModernDir>
<BaseIntermediateOutputPath>$(BasePath)artifacts\obj\$(OSPlatform)\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<SourceDir Condition="$(SourceDir) == ''">$(BasePath)src\</SourceDir>
<NugetDir Condition="$(NugetDir) == ''">$(SourceDir)</NugetDir>
<NugetOutputDir Condition="$(NugetOutputDir) == ''">$(ArtifactsDir)nuget\$(Configuration)\</NugetOutputDir>
<AddinDir>$(SourceDir)\Addins\</AddinDir>
<mdtool Condition="$(mdtool) == '' and $(OSPlatform) == 'Linux'">"mdtool"</mdtool>
<mdtool Condition="$(mdtool) == '' and $(OSPlatform) == 'Mac'">"/Applications/Xamarin Studio.app/Contents/MacOS/mdtool"</mdtool>
<mdtool Condition="$(mdtool) == '' and $(OSPlatform) == 'Windows'">"c:\Program Files (x86)\Xamarin Studio\bin\mdtool.exe"</mdtool>
<UtilitiesBasePath>$(ArtifactsDir)obj</UtilitiesBasePath>

<VersionInfoPropsFile>$(ArtifactsDir)obj\VersionInfo.props</VersionInfoPropsFile>

</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions build/NuGet.targets
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<Target Name="BuildPackage" DependsOnTargets="_GetAssemblyInfo">
<MakeDir Directories="$(NupkgOutputDir)"/>
<PropertyGroup>
<BasePath>$(BasePath.TrimEnd('\'))</BasePath>
<NupkgOutputDir>$(NupkgOutputDir.TrimEnd('\'))</NupkgOutputDir>
<BuildCommand>$(NuGetCommand) pack "$(NuspecPath)" -BasePath "$(BasePath)" -Properties "Configuration=$(Configuration);Platform=$(Platform);$(NugetBuildProperties)" $(NonInteractiveSwitch) -OutputDirectory "$(NupkgOutputDir)" $(NugetBuildOptions)</BuildCommand>
</PropertyGroup>
<Exec Command="$(BuildCommand)" />
Expand Down
Loading

0 comments on commit 08070f0

Please sign in to comment.