Skip to content

Commit 378db56

Browse files
committed
Fixed up XAML and ASPX references to the unified DotNetOpenAuth assembly.
1 parent 8d54af3 commit 378db56

6 files changed

Lines changed: 68 additions & 0 deletions

File tree

lib/DotNetOpenAuth.BuildTasks.dll

512 Bytes
Binary file not shown.

lib/DotNetOpenAuth.BuildTasks.pdb

6 KB
Binary file not shown.

lib/DotNetOpenAuth.BuildTasks.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@
3030
<UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="PrepareOhlohRelease" />
3131
<UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="AddFilesTo7Zip" />
3232
<UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="NuGetPack" />
33+
<UsingTask AssemblyFile="DotNetOpenAuth.BuildTasks.dll" TaskName="RegexFileReplace" />
3334
</Project>

src/DotNetOpenAuth.BuildTasks/DotNetOpenAuth.BuildTasks.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<Compile Include="ChangeProjectReferenceToAssemblyReference.cs" />
104104
<Compile Include="CompareFiles.cs" />
105105
<Compile Include="ChangeAssemblyReference.cs" />
106+
<Compile Include="RegexFileReplace.cs" />
106107
<Compile Include="CopyWithTokenSubstitution.cs" />
107108
<Compile Include="CreateWebApplication.cs" />
108109
<Compile Include="DeleteWebApplication.cs" />
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="RegexFileReplace.cs" company="Andrew Arnott">
3+
// Copyright (c) Andrew Arnott. All rights reserved.
4+
// </copyright>
5+
//-----------------------------------------------------------------------
6+
7+
namespace DotNetOpenAuth.BuildTasks {
8+
using System;
9+
using System.Collections.Generic;
10+
using System.IO;
11+
using System.Linq;
12+
using System.Reflection;
13+
using System.Text;
14+
using Microsoft.Build.BuildEngine;
15+
using Microsoft.Build.Framework;
16+
using Microsoft.Build.Utilities;
17+
using System.Text.RegularExpressions;
18+
19+
public class RegexFileReplace : Task {
20+
/// <summary>
21+
/// Gets or sets the set of files to search.
22+
/// </summary>
23+
[Required]
24+
public ITaskItem[] Files { get; set; }
25+
26+
/// <summary>
27+
/// Gets or sets the files to save the changed files to. This may be the same as the input files to make the change in place.
28+
/// </summary>
29+
public ITaskItem[] OutputFiles { get; set; }
30+
31+
public string Pattern { get; set; }
32+
33+
public string Replacement { get; set; }
34+
35+
/// <summary>
36+
/// Executes this instance.
37+
/// </summary>
38+
public override bool Execute() {
39+
if (this.OutputFiles == null || this.OutputFiles.Length == 0) {
40+
this.OutputFiles = this.Files;
41+
}
42+
43+
foreach (var file in this.Files) {
44+
string[] lines = File.ReadAllLines(file.ItemSpec);
45+
for (int i = 0; i < lines.Length; i++) {
46+
lines[i] = Regex.Replace(lines[i], this.Pattern, this.Replacement);
47+
}
48+
49+
File.WriteAllLines(file.ItemSpec, lines);
50+
}
51+
52+
return !this.Log.HasLoggedErrors;
53+
}
54+
}
55+
}

tools/drop.proj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
$(ProjectRoot)Samples\**\*.refresh_;
8080
$(ProjectRoot)Samples\*.proj;
8181
" />
82+
<DropSamplesSourceFiles Include="$(ProjectRoot)Samples\**\Bin\*.refresh" />
8283
<!-- Some .refresh files are only applicable to drop builds, so we rename them from *.refresh_ -->
8384
<DropSamplesRefreshSourceFiles Include="$(ProjectRoot)Samples\**\*.refresh_" />
8485
<DropSpecsSourceFiles Include="$(ProjectRoot)Doc\specs\*.htm*" />
@@ -135,6 +136,16 @@
135136
AddReferences="Microsoft.Contracts"/>
136137
<ChangeProjectReferenceToAssemblyReference Projects="@(SampleProjectTargets)"
137138
ProjectReferences="@(ProjectReferencesToRemove)" References="@(AssemblyReferencesToReplaceWith)" />
139+
<RegexFileReplace
140+
Files="@(DropSamplesFiles)"
141+
Pattern='&lt;%@ Register Assembly="DotNetOpenAuth[^"]+"'
142+
Replacement='&lt;%@ Register Assembly="DotNetOpenAuth"'
143+
Condition=" '%(Extension)' == '.aspx' " />
144+
<RegexFileReplace
145+
Files="@(DropSamplesFiles)"
146+
Pattern='xmlns\:(.+)assembly=DotNetOpenAuth([^;"]+)'
147+
Replacement='xmlns:$1assembly=DotNetOpenAuth'
148+
Condition=" '%(Extension)' == '.xaml' " />
138149
<DowngradeProjects
139150
Projects="@(SampleProjectTargets);@(SampleSolutionTargets)"
140151
DowngradeMvc2ToMvc1="$(DowngradeMvc2ToMvc1)"

0 commit comments

Comments
 (0)