summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2010-07-21 19:11:45 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2010-07-21 19:11:45 -0700
commit9533f64c85a79b80fb51843d151fa2046dc62b9c (patch)
tree21a9d5e86e6d8e5c975e9701b1553745e82aeda3
parent3c09e09a3c850f2a2b86b4f97b3fbf738c436e6a (diff)
downloadDotNetOpenAuth-9533f64c85a79b80fb51843d151fa2046dc62b9c.zip
DotNetOpenAuth-9533f64c85a79b80fb51843d151fa2046dc62b9c.tar.gz
DotNetOpenAuth-9533f64c85a79b80fb51843d151fa2046dc62b9c.tar.bz2
Downgrading VS2010 sample projects to VS2008 now happens by creating NEW project and solution files rather than wiping out the VS2010 ones.
So now VS2008 and VS2010 users have solutions and projects they can open immediately.
-rw-r--r--lib/DotNetOpenAuth.BuildTasks.dllbin99840 -> 101376 bytes
-rw-r--r--lib/DotNetOpenAuth.BuildTasks.pdbbin241152 -> 243200 bytes
-rw-r--r--src/DotNetOpenAuth.BuildTasks/DowngradeProjects.cs47
-rw-r--r--tools/drop.proj6
4 files changed, 49 insertions, 4 deletions
diff --git a/lib/DotNetOpenAuth.BuildTasks.dll b/lib/DotNetOpenAuth.BuildTasks.dll
index 5a35fa4..26367b6 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 e7be47e..242acd9 100644
--- a/lib/DotNetOpenAuth.BuildTasks.pdb
+++ b/lib/DotNetOpenAuth.BuildTasks.pdb
Binary files differ
diff --git a/src/DotNetOpenAuth.BuildTasks/DowngradeProjects.cs b/src/DotNetOpenAuth.BuildTasks/DowngradeProjects.cs
index b545541..2188cd0 100644
--- a/src/DotNetOpenAuth.BuildTasks/DowngradeProjects.cs
+++ b/src/DotNetOpenAuth.BuildTasks/DowngradeProjects.cs
@@ -10,6 +10,7 @@ namespace DotNetOpenAuth.BuildTasks {
using System.IO;
using System.Linq;
using System.Text;
+ using System.Text.RegularExpressions;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
@@ -24,6 +25,9 @@ namespace DotNetOpenAuth.BuildTasks {
[Required]
public ITaskItem[] Projects { get; set; }
+ [Output]
+ public ITaskItem[] DowngradedProjects { get; set; }
+
/// <summary>
/// Gets or sets a value indicating whether ASP.NET MVC 2 projects are downgraded to MVC 1.0.
/// </summary>
@@ -33,11 +37,26 @@ namespace DotNetOpenAuth.BuildTasks {
/// Executes this instance.
/// </summary>
public override bool Execute() {
+ var newProjectToOldProjectMapping = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ var createdProjectFiles = new List<TaskItem>();
+
+ foreach (ITaskItem taskItem in this.Projects) {
+ switch (GetClassification(taskItem)) {
+ case ProjectClassification.VS2010Project:
+ case ProjectClassification.VS2010Solution:
+ string projectNameForVS2008 = Path.Combine(
+ Path.GetDirectoryName(taskItem.ItemSpec),
+ Path.GetFileNameWithoutExtension(taskItem.ItemSpec) + "-vs2008" + Path.GetExtension(taskItem.ItemSpec));
+ newProjectToOldProjectMapping[taskItem.ItemSpec] = projectNameForVS2008;
+ break;
+ }
+ }
+
foreach (ITaskItem taskItem in this.Projects) {
switch (GetClassification(taskItem)) {
case ProjectClassification.VS2010Project:
this.Log.LogMessage(MessageImportance.Low, "Downgrading project \"{0}\".", taskItem.ItemSpec);
- Project project = new Project();
+ var project = new Project();
project.Load(taskItem.ItemSpec);
project.DefaultToolsVersion = "3.5";
@@ -66,7 +85,18 @@ namespace DotNetOpenAuth.BuildTasks {
project.AddNewItem("Reference", "System.Core");
}
- project.Save(taskItem.ItemSpec);
+ // Rewrite ProjectReferences to other renamed projects.
+ BuildItemGroup projectReferences = project.GetEvaluatedItemsByName("ProjectReference");
+ foreach (var mapping in newProjectToOldProjectMapping) {
+ string oldName = Path.GetFileName(mapping.Key);
+ string newName = Path.GetFileName(mapping.Value);
+ foreach (BuildItem projectReference in projectReferences) {
+ projectReference.Include = Regex.Replace(projectReference.Include, oldName, newName, RegexOptions.IgnoreCase);
+ }
+ }
+
+ project.Save(newProjectToOldProjectMapping[taskItem.ItemSpec]);
+ createdProjectFiles.Add(new TaskItem(taskItem) { ItemSpec = newProjectToOldProjectMapping[taskItem.ItemSpec] });
break;
case ProjectClassification.VS2010Solution:
this.Log.LogMessage(MessageImportance.Low, "Downgrading solution \"{0}\".", taskItem.ItemSpec);
@@ -84,7 +114,16 @@ namespace DotNetOpenAuth.BuildTasks {
contents[i] = contents[i].Replace("TargetFrameworkMoniker = \".NETFramework,Version%3Dv", "TargetFramework = \"");
}
- File.WriteAllLines(taskItem.ItemSpec, contents);
+ foreach (var mapping in newProjectToOldProjectMapping) {
+ string oldName = Path.GetFileName(mapping.Key);
+ string newName = Path.GetFileName(mapping.Value);
+ for (int i = 0; i < contents.Length; i++) {
+ contents[i] = Regex.Replace(contents[i], oldName, newName, RegexOptions.IgnoreCase);
+ }
+ }
+
+ File.WriteAllLines(newProjectToOldProjectMapping[taskItem.ItemSpec], contents);
+ createdProjectFiles.Add(new TaskItem(taskItem) { ItemSpec = newProjectToOldProjectMapping[taskItem.ItemSpec] });
break;
default:
this.Log.LogWarning("Unrecognized project type for \"{0}\".", taskItem.ItemSpec);
@@ -92,6 +131,8 @@ namespace DotNetOpenAuth.BuildTasks {
}
}
+ this.DowngradedProjects = createdProjectFiles.ToArray();
+
return !this.Log.HasLoggedErrors;
}
diff --git a/tools/drop.proj b/tools/drop.proj
index 6720ae3..4ceb6bd 100644
--- a/tools/drop.proj
+++ b/tools/drop.proj
@@ -72,7 +72,7 @@
$(ProjectRoot)**\*~;
$(ProjectRoot)**\Debug\**;
$(ProjectRoot)**\StyleCop.Cache;
- $(ProjectRoot)Samples\_ReSharper.Samples\**;
+ $(ProjectRoot)Samples\_ReSharper.*\**;
$(ProjectRoot)Samples\**\DotNetOpenAuth.???;
$(ProjectRoot)Samples\**\DotNetOpenAuth.resources.???;
$(ProjectRoot)Samples\**\log4net.???;
@@ -142,6 +142,10 @@
DowngradeMvc2ToMvc1="$(DowngradeMvc2ToMvc1)"
Condition=" '$(DowngradeVS2010ToVS2008)' != 'false' "
/>
+ <ItemGroup>
+ <!-- Go snag the newly created files so that .zip file will include them. -->
+ <AllDropTargets Include="$(DropSamplesDirectory)**\*-vs2008.*" />
+ </ItemGroup>
</Target>
<Target Name="Build" DependsOnTargets="Layout" Returns="@(RedistributableFiles)">