summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.proj1
-rw-r--r--lib/DotNetOpenAuth.BuildTasks.dllbin56832 -> 57856 bytes
-rw-r--r--lib/DotNetOpenAuth.BuildTasks.pdbbin142848 -> 144896 bytes
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln2
-rw-r--r--src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs34
-rw-r--r--src/DotNetOpenAuth.BuildTasks/Purge.cs2
-rw-r--r--src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs6
-rw-r--r--tools/DotNetOpenAuth.Common.Settings.targets2
-rw-r--r--tools/DotNetOpenAuth.Versioning.targets18
-rw-r--r--tools/Translation.targets39
10 files changed, 96 insertions, 8 deletions
diff --git a/build.proj b/build.proj
index bf0ab20..c0321ad 100644
--- a/build.proj
+++ b/build.proj
@@ -12,6 +12,7 @@
<Import Project="$(ProjectRoot)tools\$(ProductName).Versioning.targets"/>
<Import Project="$(ProjectRoot)tools\Documentation.targets"/>
<Import Project="$(ProjectRoot)tools\Publish.targets"/>
+ <Import Project="$(ProjectRoot)tools\Translation.targets"/>
<UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="Zip"/>
<UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="ILMerge"/>
diff --git a/lib/DotNetOpenAuth.BuildTasks.dll b/lib/DotNetOpenAuth.BuildTasks.dll
index 1958acc..9dfd63e 100644
--- a/lib/DotNetOpenAuth.BuildTasks.dll
+++ b/lib/DotNetOpenAuth.BuildTasks.dll
Binary files differ
diff --git a/lib/DotNetOpenAuth.BuildTasks.pdb b/lib/DotNetOpenAuth.BuildTasks.pdb
index b8fd372..b27ee26 100644
--- a/lib/DotNetOpenAuth.BuildTasks.pdb
+++ b/lib/DotNetOpenAuth.BuildTasks.pdb
Binary files differ
diff --git a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
index c875882..fca41e8 100644
--- a/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
+++ b/src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.sln
@@ -7,6 +7,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
..\..\build.proj = ..\..\build.proj
..\..\lib\DotNetOpenAuth.BuildTasks.targets = ..\..\lib\DotNetOpenAuth.BuildTasks.targets
+ ..\..\tools\DotNetOpenAuth.Common.Settings.targets = ..\..\tools\DotNetOpenAuth.Common.Settings.targets
+ ..\..\tools\DotNetOpenAuth.Versioning.targets = ..\..\tools\DotNetOpenAuth.Versioning.targets
EndProjectSection
EndProject
Global
diff --git a/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs b/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs
index e40eb78..48b5d5c 100644
--- a/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs
+++ b/src/DotNetOpenAuth.BuildTasks/GetBuildVersion.cs
@@ -16,16 +16,29 @@ namespace DotNetOpenAuth.BuildTasks {
public string Version { get; private set; }
/// <summary>
+ /// Gets the Git revision control commit id for HEAD (the current source code version).
+ /// </summary>
+ [Output]
+ public string GitCommitId { get; private set; }
+
+ /// <summary>
/// The file that contains the version base (Major.Minor.Build) to use.
/// </summary>
[Required]
public string VersionFile { get; set; }
+ /// <summary>
+ /// Gets or sets the parent directory of the .git directory.
+ /// </summary>
+ public string GitRepoRoot { get; set; }
+
public override bool Execute() {
try {
Version typedVersion = ReadVersionFromFile();
typedVersion = new Version(typedVersion.Major, typedVersion.Minor, typedVersion.Build, CalculateJDate(DateTime.Now));
Version = typedVersion.ToString();
+
+ this.GitCommitId = GetGitHeadCommitId();
} catch (ArgumentOutOfRangeException ex) {
Log.LogErrorFromException(ex);
return false;
@@ -34,6 +47,25 @@ namespace DotNetOpenAuth.BuildTasks {
return true;
}
+ private string GetGitHeadCommitId() {
+ if (string.IsNullOrEmpty(this.GitRepoRoot)) {
+ return string.Empty;
+ }
+
+ string headContent = string.Empty;
+ try {
+ headContent = File.ReadAllText(Path.Combine(this.GitRepoRoot, @".git/HEAD")).Trim();
+ if (headContent.StartsWith("ref:", StringComparison.Ordinal)) {
+ string refName = headContent.Substring(5).Trim();
+ headContent = File.ReadAllText(Path.Combine(this.GitRepoRoot, @".git/" + refName)).Trim();
+ }
+ } catch (FileNotFoundException) {
+ } catch (DirectoryNotFoundException) {
+ }
+
+ return headContent.Trim();
+ }
+
private Version ReadVersionFromFile() {
string[] lines = File.ReadAllLines(VersionFile);
string versionLine = lines[0];
@@ -41,7 +73,7 @@ namespace DotNetOpenAuth.BuildTasks {
}
private int CalculateJDate(DateTime date) {
- int yearLastDigit = date.Year % 10;
+ int yearLastDigit = date.Year - 2000; // can actually be two digits in or after 2010
DateTime firstOfYear = new DateTime(date.Year, 1, 1);
int dayOfYear = (date - firstOfYear).Days + 1;
int jdate = yearLastDigit * 1000 + dayOfYear;
diff --git a/src/DotNetOpenAuth.BuildTasks/Purge.cs b/src/DotNetOpenAuth.BuildTasks/Purge.cs
index f23a6d9..e19e485 100644
--- a/src/DotNetOpenAuth.BuildTasks/Purge.cs
+++ b/src/DotNetOpenAuth.BuildTasks/Purge.cs
@@ -56,7 +56,7 @@ namespace DotNetOpenAuth.BuildTasks {
public override bool Execute() {
HashSet<string> intendedFiles = new HashSet<string>(this.IntendedFiles.Select(file => file.GetMetadata("FullPath")), StringComparer.OrdinalIgnoreCase);
- foreach (string directory in this.Directories.Select(dir => NormalizePath(dir))) {
+ foreach (string directory in this.Directories.Select(dir => NormalizePath(dir)).Where(dir => Directory.Exists(dir))) {
foreach (string existingFile in Directory.GetFiles(directory, "*", SearchOption.AllDirectories)) {
if (!intendedFiles.Contains(existingFile)) {
this.Log.LogWarning("Purging file \"{0}\".", existingFile);
diff --git a/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs b/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs
index 75b4efd..00468ed 100644
--- a/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs
+++ b/src/DotNetOpenAuth/OpenId/OpenIdXrdsHelper.cs
@@ -143,8 +143,10 @@ namespace DotNetOpenAuth.OpenId {
/// <param name="userSuppliedIdentifier">The i-name supplied by the user.</param>
/// <returns>A sequence of the providers that can assert ownership of the given identifier.</returns>
private static IEnumerable<IdentifierDiscoveryResult> GenerateClaimedIdentifierServiceEndpoints(this IEnumerable<XrdElement> xrds, XriIdentifier userSuppliedIdentifier) {
- Contract.Requires<ArgumentNullException>(xrds != null);
- Contract.Ensures(Contract.Result<IEnumerable<IdentifierDiscoveryResult>>() != null);
+ // Cannot use code contracts because this method uses yield return.
+ ////Contract.Requires<ArgumentNullException>(xrds != null);
+ ////Contract.Ensures(Contract.Result<IEnumerable<IdentifierDiscoveryResult>>() != null);
+ ErrorUtilities.VerifyArgumentNotNull(xrds, "xrds");
foreach (var service in xrds.FindClaimedIdentifierServices()) {
foreach (var uri in service.UriElements) {
diff --git a/tools/DotNetOpenAuth.Common.Settings.targets b/tools/DotNetOpenAuth.Common.Settings.targets
index 34e14f5..7a8276c 100644
--- a/tools/DotNetOpenAuth.Common.Settings.targets
+++ b/tools/DotNetOpenAuth.Common.Settings.targets
@@ -19,6 +19,6 @@
<CheckAdminRights>
<Output TaskParameter="IsElevated" PropertyName="IsElevated" />
</CheckAdminRights>
- <Message Importance="High" Text="IsElevated = $(IsElevated)" />
+ <Message Importance="High" Text="IsElevated = $(IsElevated)" />
</Target>
</Project>
diff --git a/tools/DotNetOpenAuth.Versioning.targets b/tools/DotNetOpenAuth.Versioning.targets
index 6a4b95a..5047f3a 100644
--- a/tools/DotNetOpenAuth.Versioning.targets
+++ b/tools/DotNetOpenAuth.Versioning.targets
@@ -5,6 +5,7 @@
<PropertyGroup>
<ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..\</ProjectRoot>
<VersionCsFile>$(ProjectRoot)obj\$(Configuration)\$(AssemblyName).Version.cs</VersionCsFile>
+ <NoWarn>$(NoWarn);1607</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(SignAssembly)' == 'true'">
@@ -18,10 +19,19 @@
<UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="AssemblyInfo"/>
<Target Name="GetBuildVersion">
- <GetBuildVersion VersionFile="$(ProjectRoot)src\version.txt" Condition=" '$(BuildVersion)' == '' ">
+ <GetBuildVersion Condition=" '$(BuildVersion)' == '' "
+ VersionFile="$(ProjectRoot)src\version.txt"
+ GitRepoRoot="$(ProjectRoot)">
<Output TaskParameter="Version" PropertyName="BuildVersion" />
+ <Output TaskParameter="GitCommitId" PropertyName="AssemblyInformationalVersion" />
</GetBuildVersion>
- <Message Text="Building version $(BuildVersion)"/>
+ <PropertyGroup>
+ <!-- In TeamCity, the build agent doesn't get the .git directory, but the commit id is available by other means. -->
+ <AssemblyInformationalVersion Condition=" '$(AssemblyInformationalVersion)' == '' ">$(BUILD_VCS_NUMBER)</AssemblyInformationalVersion>
+ </PropertyGroup>
+ <Warning Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Unable to determine the git HEAD commit ID to use for informational version number." />
+ <Message Condition=" '$(AssemblyInformationalVersion)' != '' " Text="Building version $(BuildVersion) from commit $(AssemblyInformationalVersion)"/>
+ <Message Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Building version $(BuildVersion)"/>
</Target>
<Target Name="BeforeBuild" DependsOnTargets="GetBuildVersion">
@@ -29,7 +39,9 @@
<NewVersionCsFile>$(VersionCsFile).new</NewVersionCsFile>
</PropertyGroup>
<MakeDir Directories="$(ProjectRoot)obj\$(Configuration)"/>
- <AssemblyInfo OutputFile="$(NewVersionCsFile)" CodeLanguage="C#" AssemblyVersion="$(BuildVersion)" />
+ <AssemblyInfo OutputFile="$(NewVersionCsFile)" CodeLanguage="C#"
+ AssemblyVersion="$(BuildVersion)"
+ AssemblyInformationalVersion="$(AssemblyInformationalVersion)" />
<!-- Avoid applying the newly generated AssemblyInfo.cs file to the build
unless it has changed in order to allow for incremental building. -->
<CompareFiles OriginalItems="$(VersionCsFile)" NewItems="$(NewVersionCsFile)">
diff --git a/tools/Translation.targets b/tools/Translation.targets
new file mode 100644
index 0000000..21b27be
--- /dev/null
+++ b/tools/Translation.targets
@@ -0,0 +1,39 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ExportedTxtResourcesIntermediateDir>$(IntermediatePath)ExportedTxtResources</ExportedTxtResourcesIntermediateDir>
+ <ExportedTxtResourcesIntermediateDir Condition=" '$(Culture)' != '' ">$(ExportedTxtResourcesIntermediateDir).$(Culture)</ExportedTxtResourcesIntermediateDir>
+ <ExportedTxtResourcesIntermediateDir>$(ExportedTxtResourcesIntermediateDir)\</ExportedTxtResourcesIntermediateDir>
+
+ <ExportedTxtResourcesZip>$(IntermediatePath)$(ProductName) resources</ExportedTxtResourcesZip>
+ <ExportedTxtResourcesZip Condition=" '$(Culture)' != '' ">$(ExportedTxtResourcesZip).$(Culture)</ExportedTxtResourcesZip>
+ <ExportedTxtResourcesZip>$(ExportedTxtResourcesZip).zip</ExportedTxtResourcesZip>
+ </PropertyGroup>
+ <Target Name="ExportResX">
+ <ItemGroup Condition=" '$(Culture)' != '' " >
+ <ResXFilesToExport Include="$(ProjectRoot)src\$(ProductName)\**\*.$(Culture).resx" />
+ </ItemGroup>
+ <PropertyGroup>
+ <ResXNewCulture Condition=" '@(ResXFilesToExport)' == '' ">.$(Culture)</ResXNewCulture>
+ </PropertyGroup>
+ <ItemGroup Condition=" '$(Culture)' == '' or '$(ResXNewCulture)' != '' ">
+ <ResXFilesToExport Include="$(ProjectRoot)src\$(ProductName)\**\*.resx" />
+ <ResXFilesToExport Remove="$(ProjectRoot)src\$(ProductName)\**\*.*.resx" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResXFilesToExport>
+ <ExportedFullPath>$(ExportedTxtResourcesIntermediateDir)%(RecursiveDir)%(FileName)$(ResXNewCulture).txt</ExportedFullPath>
+ <ExportedDirectory>$(ExportedTxtResourcesIntermediateDir)%(RecursiveDir)</ExportedDirectory>
+ </ResXFilesToExport>
+ <ExportedTxtDirectories Include="@(ResXFilesToExport->'%(ExportedDirectory)')" />
+ <ExportedTxtFiles Include="@(ResXFilesToExport->'%(ExportedFullPath)')" />
+ </ItemGroup>
+ <Warning Condition=" '$(ResXNewCulture)' != '' " Text="No culture '$(Culture)' exists in the source project. Synthesizing new one from default culture." />
+ <MakeDir Directories="%(ResXFilesToExport.ExportedDirectory)" Condition="!Exists('%(ResXFilesToExport.ExportedDirectory)')" />
+ <Exec Command="resgen.exe %(ResXFilesToExport.Identity) %(ResXFilesToExport.ExportedFullPath)" />
+ <Purge Directories="@(ExportedTxtDirectories)" IntendedFiles="@(ExportedTxtFiles)" />
+ <Delete Files="$(ExportedTxtResourcesZip)" />
+ <Zip ZipFileName="$(ExportedTxtResourcesZip)"
+ WorkingDirectory="$(ExportedTxtResourcesIntermediateDir)"
+ Files="@(ExportedTxtFiles)" />
+ </Target>
+</Project> \ No newline at end of file