Browse Source

Allow overriding the BranchName (necessary on build server)

pull/1/head
Daniel Grunwald 15 years ago
parent
commit
b6f4ade7b4
  1. 3
      src/Automated.proj
  2. 6
      src/Main/Core/Project/ICSharpCode.Core.csproj
  3. 3
      src/Tools/Tools.build
  4. 8
      src/Tools/UpdateAssemblyInfo/Main.cs

3
src/Automated.proj

@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
<BuildProperties>$(BuildProperties) &quot;/p:SharpDevelopBinPath=$(SharpDevelopBin)&quot;</BuildProperties>
<BuildProperties>$(BuildProperties) &quot;/p:BooBinPath=$(SharpDevelopSrc)\AddIns\BackendBindings\Boo\RequiredLibraries&quot;</BuildProperties>
<BuildProperties>$(BuildProperties) &quot;/p:FSharpBuildTasksPath=$(SharpDevelopSrc)\AddIns\BackendBindings\FSharp\RequiredLibraries&quot;</BuildProperties>
<BuildProperties>$(BuildProperties) &quot;/p:BranchName=$(BranchName)&quot;</BuildProperties>
<BuildProperties>$(BuildProperties) $(AdditionalBuildProperties)</BuildProperties>
</PropertyGroup>
@ -56,7 +57,7 @@ @@ -56,7 +57,7 @@
<Target Name="build">
<MSBuild Projects="$(SharpDevelopSrc)\Tools\Tools.build"
Targets="PrepareRelease"
Properties="Configuration=Release"/>
Properties="Configuration=Release;BranchName=$(BranchName)"/>
<!-- read content of REVISION into $(BuildNumber) -->
<XmlRead XPath="/versionInfo/version"

6
src/Main/Core/Project/ICSharpCode.Core.csproj

@ -137,11 +137,9 @@ @@ -137,11 +137,9 @@
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>..\src\Tools\UpdateAssemblyInfo\bin\Debug\UpdateAssemblyInfo.exe</PreBuildEvent>
</PropertyGroup>
<Target Name="BeforeBuild">
<MSBuild Projects="$(MSBuildProjectDirectory)\..\..\..\Tools\UpdateAssemblyInfo\UpdateAssemblyInfo.csproj" Targets="Build" Properties="Configuration=Debug"/>
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\..\..\..\Tools\UpdateAssemblyInfo\bin\Debug" Command="UpdateAssemblyInfo.exe" />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\..\..\..\Tools\UpdateAssemblyInfo\bin\Debug" Command="UpdateAssemblyInfo.exe --branchname $(BranchName)" Timeout = "60000" Condition = " '$(BranchName)' != '' " />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\..\..\..\Tools\UpdateAssemblyInfo\bin\Debug" Command="UpdateAssemblyInfo.exe" Timeout = "60000" Condition = " '$(BranchName)' == '' " />
</Target>
</Project>

3
src/Tools/Tools.build

@ -55,7 +55,8 @@ @@ -55,7 +55,8 @@
<Target Name="PrepareRelease">
<!--<MSBuild Projects="@(PrepareReleaseProject)" Targets="Build"/>-->
<MSBuild Projects="UpdateAssemblyInfo\UpdateAssemblyInfo.csproj" Targets="Build" Properties="Configuration=Debug"/>
<Exec Command="UpdateAssemblyInfo.exe --REVISION" WorkingDirectory = "UpdateAssemblyInfo\bin\Debug" Timeout = "60000" IgnoreExitCode = "false"/>
<Exec Command="UpdateAssemblyInfo.exe --REVISION --branchname $(BranchName)" WorkingDirectory = "UpdateAssemblyInfo\bin\Debug" Timeout = "60000" Condition = " '$(BranchName)' != '' "/>
<Exec Command="UpdateAssemblyInfo.exe --REVISION" WorkingDirectory = "UpdateAssemblyInfo\bin\Debug" Timeout = "60000" Condition = " '$(BranchName)' == '' "/>
</Target>
<ItemGroup>

8
src/Tools/UpdateAssemblyInfo/Main.cs

@ -84,6 +84,10 @@ namespace UpdateAssemblyInfo @@ -84,6 +84,10 @@ namespace UpdateAssemblyInfo
return 2;
}
RetrieveRevisionNumber();
for (int i = 0; i < args.Length; i++) {
if (args[i] == "--branchname" && i + 1 < args.Length && !string.IsNullOrEmpty(args[i+1]))
gitBranchName = args[i + 1];
}
UpdateFiles();
if (args.Contains("--REVISION")) {
var doc = new XDocument(new XElement(
@ -117,8 +121,8 @@ namespace UpdateAssemblyInfo @@ -117,8 +121,8 @@ namespace UpdateAssemblyInfo
content = content.Replace("$INSERTDATE$", DateTime.Now.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture));
content = content.Replace("$INSERTYEAR$", DateTime.Now.Year.ToString());
content = content.Replace("$INSERTBRANCHNAME$", gitBranchName);
bool isDefaultBrach = string.IsNullOrEmpty(gitBranchName) || gitBranchName == "master" || char.IsDigit(gitBranchName, 0);
content = content.Replace("$INSERTBRANCHPOSTFIX$", isDefaultBrach ? "" : ("-" + gitBranchName));
bool isDefaultBranch = string.IsNullOrEmpty(gitBranchName) || gitBranchName == "master" || char.IsDigit(gitBranchName, 0);
content = content.Replace("$INSERTBRANCHPOSTFIX$", isDefaultBranch ? "" : ("-" + gitBranchName));
if (File.Exists(file.Output)) {
using (StreamReader r = new StreamReader(file.Output)) {
if (r.ReadToEnd() == content) {

Loading…
Cancel
Save