Skip to content

Commit

Permalink
There we go. :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihara committed Jun 24, 2014
1 parent e2f60b5 commit 7825593
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 5 deletions.
25 changes: 25 additions & 0 deletions BumpBuildNumber/BumpBuildNumber.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.IO;
using System.Text.RegularExpressions;

// This is a neat little idea I found of how to deal with the problem of non-incrementing file version on StackOverflow
// It has the advantage of not relying on a particular build system and being completely optional.

namespace BumpBuildNumber
{
class BumpBuildNumber
{
public static void Main(string[] args)
{
try {
string FILE = @"SharedAssemblyInfo.cs";
string text = File.ReadAllText(FILE);
var regex = new Regex(@"(?<STATIC>\[assembly: AssemblyFileVersion\(""\d+\.\d+\.\d+\.)(?<BUILD>\d+)(?<TRAILER>""\)\])");
var match = regex.Match(text);
int buildNumber = int.Parse(match.Groups["BUILD"].Value) + 1;
string newText = regex.Replace(text, "${STATIC}" + buildNumber + "${TRAILER}", 1);
File.WriteAllText(FILE, newText);
} catch {
}
}
}
}
40 changes: 40 additions & 0 deletions BumpBuildNumber/BumpBuildNumber.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{059C7AF3-35D8-4F54-B1C9-8914E59CB5A6}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>BumpBuildNumber</RootNamespace>
<AssemblyName>BumpBuildNumber</AssemblyName>
<ReleaseVersion>0.17</ReleaseVersion>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>..\bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="BumpBuildNumber.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
27 changes: 27 additions & 0 deletions BumpBuildNumber/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("BumpBuildNumber")]
[assembly: AssemblyDescription("A simple build utility to automate bumping build numbers without learning MSBuild tricks under Xamarin.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Eugene Medvedev")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

2 changes: 1 addition & 1 deletion FormatterTests/FormatterTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7FF5F186-3C9C-4E75-B71A-B0C248365D75}</ProjectGuid>
<OutputType>Exe</OutputType>
Expand Down
6 changes: 6 additions & 0 deletions RasterPropMonitor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormatterTests", "Formatter
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MechJebRPM", "MechJebRPM\MechJebRPM.csproj", "{272BB11D-C8A8-4CA8-8C18-58324670C68C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BumpBuildNumber", "BumpBuildNumber\BumpBuildNumber.csproj", "{059C7AF3-35D8-4F54-B1C9-8914E59CB5A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{059C7AF3-35D8-4F54-B1C9-8914E59CB5A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{059C7AF3-35D8-4F54-B1C9-8914E59CB5A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{059C7AF3-35D8-4F54-B1C9-8914E59CB5A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{059C7AF3-35D8-4F54-B1C9-8914E59CB5A6}.Release|Any CPU.Build.0 = Release|Any CPU
{272BB11D-C8A8-4CA8-8C18-58324670C68C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{272BB11D-C8A8-4CA8-8C18-58324670C68C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{272BB11D-C8A8-4CA8-8C18-58324670C68C}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
5 changes: 5 additions & 0 deletions RasterPropMonitor/RasterPropMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<LangVersion>4</LangVersion>
<CustomCommands>
<CustomCommands>
<Command type="BeforeBuild" command="..\bin\Release\BumpBuildNumber.exe" workingdir="${SolutionDir}" />
</CustomCommands>
</CustomCommands>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
9 changes: 5 additions & 4 deletions SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
[assembly: AssemblyVersion("0.17.0.0")]

// Now this is the actual version number with build number.
// As I release newer ones, I'll bump them. Unfortunately I can't make automatic build number bumping
// without jumping through a lot of hoops.
// The 8888 is temporary here.
[assembly: AssemblyFileVersion("0.17.8888.0")]
// As I release newer ones, I'll bump them manually.
// The 8888 is temporary here to distinguish this from the last built dev build packet,
// as I release 0.17, I'll switch the version to 0.17.
// Build number is altered automatically.
[assembly: AssemblyFileVersion("0.17.8888.3")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down

0 comments on commit 7825593

Please sign in to comment.