Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/tools
diff options
context:
space:
mode:
authorAnkit Jain <radical@corewars.org>2009-09-27 00:49:54 +0400
committerAnkit Jain <radical@corewars.org>2009-09-27 00:49:54 +0400
commitc5cbb9cb4b612174b1f40760190c8f34cb3560d4 (patch)
treeac164fbeda990ec9d732f4b8d7dae7e031307cb6 /mcs/tools
parent95ab6bc64de11405b602fc06d8dd894f640b000f (diff)
Update xbuild and Microsoft.Build.* from trunk.
In tools/xbuild: 2009-09-27 Ankit Jain <jankit@novell.com> * SolutionParser.cs: Implement support for WebSite projects. These projects lack a project file, so properties like references are read from the .sln file, and targets are generated for build/clean etc. 2009-09-26 Ankit Jain <jankit@novell.com> * xbuild/Microsoft.Common.targets: Remove _ValidateEssentialProperties from BuildDependsOn, which was a hack. It will get invoked from the InitialTargets now. In class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine: 2009-09-26 Ankit Jain <jankit@novell.com> * TargetTest.cs (TestOverridingTargets): New. 2009-09-26 Ankit Jain <jankit@novell.com> * ProjectTest.cs (TestInitialTargetsWithImports): (TestDefaultTargets): (TestDefaultTargetsWithImports): (TestNoDefaultTargetsWithImports): (TestNoDefaultTargets): New tests. In class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine: 2009-09-27 Ankit Jain <jankit@novell.com> * ConditionParser.cs: Show the condition being parsed in the exception message. 2009-09-26 Ankit Jain <jankit@novell.com> * Expression.cs: Allow '-' in item, property and metadata names. 2009-09-26 Ankit Jain <jankit@novell.com> * Project.cs (Evaluate): Split into this and .. (PrepareForEvaluate): .. this. (AddImport): Evaluate the current set of properties/items etc, before processing the imported project. Honor the Condition for the Import. (ProcessProjectAttributes): Update MSBuildProjectDefaultTargets property. * GroupingCollection.cs (Evaluate): Don't evaluate Imports here. * BuildItemGroup.cs (Evaluate): Evaluate only once. * BuildPropertyGroup.cs (Evaluate): Evaluate only once. 2009-09-26 Ankit Jain <jankit@novell.com> * Project.cs: Get InitialTargets from the imported projects also. The combined list of targets are executed, in the order they were found. DefaultTargets are also read in from imported projects, and the first non-empty DefaultTargets found is used. svn path=/branches/mono-2-6/mcs/; revision=142686
Diffstat (limited to 'mcs/tools')
-rw-r--r--mcs/tools/xbuild/ChangeLog12
-rw-r--r--mcs/tools/xbuild/SolutionParser.cs396
-rw-r--r--mcs/tools/xbuild/xbuild/Microsoft.Common.targets1
3 files changed, 367 insertions, 42 deletions
diff --git a/mcs/tools/xbuild/ChangeLog b/mcs/tools/xbuild/ChangeLog
index 2937953d4c5..a8ec63241d5 100644
--- a/mcs/tools/xbuild/ChangeLog
+++ b/mcs/tools/xbuild/ChangeLog
@@ -1,3 +1,15 @@
+2009-09-27 Ankit Jain <jankit@novell.com>
+
+ * SolutionParser.cs: Implement support for WebSite projects. These
+ projects lack a project file, so properties like references are read
+ from the .sln file, and targets are generated for build/clean etc.
+
+2009-09-26 Ankit Jain <jankit@novell.com>
+
+ * xbuild/Microsoft.Common.targets: Remove _ValidateEssentialProperties
+ from BuildDependsOn, which was a hack. It will get invoked from the
+ InitialTargets now.
+
2009-09-25 Ankit Jain <jankit@novell.com>
* Makefile(EXTRA_DISTFILES): Add Microsoft.WebApplication.targets
diff --git a/mcs/tools/xbuild/SolutionParser.cs b/mcs/tools/xbuild/SolutionParser.cs
index 80ebc43f671..9a8d1110d57 100644
--- a/mcs/tools/xbuild/SolutionParser.cs
+++ b/mcs/tools/xbuild/SolutionParser.cs
@@ -41,6 +41,7 @@ namespace Mono.XBuild.CommandLine {
class ProjectInfo {
public string Name;
public string FileName;
+ public Guid Guid;
public ProjectInfo (string name, string fileName)
{
@@ -50,6 +51,18 @@ namespace Mono.XBuild.CommandLine {
public Dictionary<TargetInfo, TargetInfo> TargetMap = new Dictionary<TargetInfo, TargetInfo> ();
public Dictionary<Guid, ProjectInfo> Dependencies = new Dictionary<Guid, ProjectInfo> ();
+ public Dictionary<string, ProjectSection> ProjectSections = new Dictionary<string, ProjectSection> ();
+ public List<string> AspNetConfigurations = new List<string> ();
+ }
+
+ class ProjectSection {
+ public string Name;
+ public Dictionary<string, string> Properties = new Dictionary<string, string> ();
+
+ public ProjectSection (string name)
+ {
+ Name = name;
+ }
}
struct TargetInfo {
@@ -81,6 +94,7 @@ namespace Mono.XBuild.CommandLine {
static Regex projectRegex = new Regex ("Project\\(\"(" + guidExpression + ")\"\\) = \"(.*?)\", \"(.*?)\", \"(" + guidExpression + ")\"(\\s*?)((\\s*?)ProjectSection\\((.*?)\\) = (.*?)EndProjectSection(\\s*?))*(\\s*?)EndProject?", RegexOptions.Singleline);
static Regex projectDependenciesRegex = new Regex ("ProjectSection\\((.*?)\\) = \\w*(.*?)EndProjectSection", RegexOptions.Singleline);
static Regex projectDependencyRegex = new Regex ("\\s*(" + guidExpression + ") = (" + guidExpression + ")");
+ static Regex projectSectionPropertiesRegex = new Regex ("\\s*(?<name>.*) = \"(?<value>.*)\"");
static Regex globalRegex = new Regex ("Global(.*)EndGlobal", RegexOptions.Singleline);
static Regex globalSectionRegex = new Regex ("GlobalSection\\((.*?)\\) = \\w*(.*?)EndGlobalSection", RegexOptions.Singleline);
@@ -91,6 +105,7 @@ namespace Mono.XBuild.CommandLine {
static string solutionFolderGuid = "{2150E333-8FDC-42A3-9474-1A3956D46DE8}";
static string vcprojGuid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
+ static string websiteProjectGuid = "{E24C65DC-7377-472B-9ABA-BC803B73C61A}";
RaiseWarningHandler RaiseWarning;
@@ -106,6 +121,8 @@ namespace Mono.XBuild.CommandLine {
List<TargetInfo> solutionTargets = new List<TargetInfo> ();
Dictionary<Guid, ProjectInfo> projectInfos = new Dictionary<Guid, ProjectInfo> ();
+ Dictionary<Guid, ProjectInfo> websiteProjectInfos = new Dictionary<Guid, ProjectInfo> ();
+ List<ProjectInfo>[] infosByLevel = null;
Match m = projectRegex.Match (line);
while (m.Success) {
@@ -116,6 +133,7 @@ namespace Mono.XBuild.CommandLine {
m = m.NextMatch ();
continue;
}
+
if (String.Compare (m.Groups [1].Value, vcprojGuid,
StringComparison.InvariantCultureIgnoreCase) == 0) {
// Ignore vcproj
@@ -124,16 +142,37 @@ namespace Mono.XBuild.CommandLine {
continue;
}
- projectInfos.Add (new Guid (m.Groups[4].Value), projectInfo);
+ if (String.Compare (m.Groups [1].Value, websiteProjectGuid,
+ StringComparison.InvariantCultureIgnoreCase) == 0)
+ websiteProjectInfos.Add (new Guid (m.Groups[4].Value), projectInfo);
+ else
+ projectInfos.Add (new Guid (m.Groups[4].Value), projectInfo);
+
+ projectInfo.Guid = new Guid (m.Groups [4].Value);
Match projectSectionMatch = projectDependenciesRegex.Match (m.Groups[6].Value);
while (projectSectionMatch.Success) {
- Match projectDependencyMatch = projectDependencyRegex.Match (projectSectionMatch.Value);
- while (projectDependencyMatch.Success) {
- // we might not have projectInfo available right now, so
- // set it to null, and fill it in later
- projectInfo.Dependencies [new Guid (projectDependencyMatch.Groups[1].Value)] = null;
- projectDependencyMatch = projectDependencyMatch.NextMatch ();
+ string section_name = projectSectionMatch.Groups [1].Value;
+ if (String.Compare (section_name, "ProjectDependencies") == 0) {
+ Match projectDependencyMatch = projectDependencyRegex.Match (projectSectionMatch.Value);
+ while (projectDependencyMatch.Success) {
+ // we might not have projectInfo available right now, so
+ // set it to null, and fill it in later
+ projectInfo.Dependencies [new Guid (projectDependencyMatch.Groups[1].Value)] = null;
+ projectDependencyMatch = projectDependencyMatch.NextMatch ();
+ }
+ } else {
+ ProjectSection section = new ProjectSection (section_name);
+ Match propertiesMatch = projectSectionPropertiesRegex.Match (
+ projectSectionMatch.Groups [2].Value);
+ while (propertiesMatch.Success) {
+ section.Properties [propertiesMatch.Groups ["name"].Value] =
+ propertiesMatch.Groups ["value"].Value;
+
+ propertiesMatch = propertiesMatch.NextMatch ();
+ }
+
+ projectInfo.ProjectSections [section_name] = section;
}
projectSectionMatch = projectSectionMatch.NextMatch ();
}
@@ -181,7 +220,8 @@ namespace Mono.XBuild.CommandLine {
ParseSolutionConfigurationPlatforms (globalSectionMatch.Groups[2].Value, solutionTargets);
break;
case "ProjectConfigurationPlatforms":
- ParseProjectConfigurationPlatforms (globalSectionMatch.Groups[2].Value, projectInfos);
+ ParseProjectConfigurationPlatforms (globalSectionMatch.Groups[2].Value,
+ projectInfos, websiteProjectInfos);
break;
case "SolutionProperties":
ParseSolutionProperties (globalSectionMatch.Groups[2].Value);
@@ -195,12 +235,16 @@ namespace Mono.XBuild.CommandLine {
globalSectionMatch = globalSectionMatch.NextMatch ();
}
- int num_levels = AddBuildLevels (p, solutionTargets, projectInfos);
+ int num_levels = AddBuildLevels (p, solutionTargets, projectInfos, ref infosByLevel);
- AddCurrentSolutionConfigurationContents (p, solutionTargets, projectInfos);
+ AddCurrentSolutionConfigurationContents (p, solutionTargets, projectInfos, websiteProjectInfos);
+ AddWebsiteProperties (p, websiteProjectInfos, projectInfos);
AddValidateSolutionConfiguration (p);
+
+ AddGetFrameworkPathTarget (p);
+ AddWebsiteTargets (p, websiteProjectInfos, projectInfos, infosByLevel, solutionTargets);
AddProjectTargets (p, solutionTargets, projectInfos);
- AddSolutionTargets (p, num_levels);
+ AddSolutionTargets (p, num_levels, websiteProjectInfos.Values);
}
void AddGeneralSettings (string solutionFile, Project p)
@@ -210,10 +254,6 @@ namespace Mono.XBuild.CommandLine {
p.AddNewUsingTaskFromAssemblyName ("CreateTemporaryVCProject", "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
p.AddNewUsingTaskFromAssemblyName ("ResolveVCProjectOutput", "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
- BuildPropertyGroup aspNetConfigurationPropertyGroup = p.AddNewPropertyGroup (true);
- aspNetConfigurationPropertyGroup.Condition = " ('$(AspNetConfiguration)' == '') ";
- aspNetConfigurationPropertyGroup.AddNewProperty ("AspNetConfiguration", "$(Configuration)");
-
string solutionFilePath = Path.GetFullPath (solutionFile);
BuildPropertyGroup solutionPropertyGroup = p.AddNewPropertyGroup (true);
solutionPropertyGroup.AddNewProperty ("SolutionDir", Path.GetDirectoryName (solutionFilePath) + Path.DirectorySeparatorChar);
@@ -234,7 +274,9 @@ namespace Mono.XBuild.CommandLine {
}
}
- void ParseProjectConfigurationPlatforms (string section, Dictionary<Guid, ProjectInfo> projectInfos)
+ // ignores the website projects, in the websiteProjectInfos
+ void ParseProjectConfigurationPlatforms (string section, Dictionary<Guid, ProjectInfo> projectInfos,
+ Dictionary<Guid, ProjectInfo> websiteProjectInfos)
{
List<Guid> missingGuids = new List<Guid> ();
Match projectConfigurationPlatform = projectConfigurationActiveCfgRegex.Match (section);
@@ -243,7 +285,9 @@ namespace Mono.XBuild.CommandLine {
ProjectInfo projectInfo;
if (!projectInfos.TryGetValue (guid, out projectInfo)) {
if (!missingGuids.Contains (guid)) {
- RaiseWarning (0, string.Format("Failed to find project {0}", guid));
+ if (!websiteProjectInfos.ContainsKey (guid))
+ // ignore website projects
+ RaiseWarning (0, string.Format("Failed to find project {0}", guid));
missingGuids.Add (guid);
}
projectConfigurationPlatform = projectConfigurationPlatform.NextMatch ();
@@ -287,12 +331,26 @@ namespace Mono.XBuild.CommandLine {
{
}
- void AddCurrentSolutionConfigurationContents (Project p, List<TargetInfo> solutionTargets, Dictionary<Guid, ProjectInfo> projectInfos)
+ void AddCurrentSolutionConfigurationContents (Project p, List<TargetInfo> solutionTargets,
+ Dictionary<Guid, ProjectInfo> projectInfos,
+ Dictionary<Guid, ProjectInfo> websiteProjectInfos)
{
- AddDefaultSolutionConfiguration (p,
- solutionTargets.Count > 0 ?
- solutionTargets [0] :
- new TargetInfo ("Debug", "Any CPU"));
+ TargetInfo default_target_info = new TargetInfo ("Debug", "Any CPU");
+ if (solutionTargets.Count > 0) {
+ bool found = false;
+ foreach (TargetInfo tinfo in solutionTargets) {
+ if (String.Compare (tinfo.Platform, "Mixed Platforms") == 0) {
+ default_target_info = tinfo;
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ default_target_info = solutionTargets [0];
+ }
+
+ AddDefaultSolutionConfiguration (p, default_target_info);
foreach (TargetInfo solutionTarget in solutionTargets) {
BuildPropertyGroup platformPropertyGroup = p.AddNewPropertyGroup (false);
@@ -302,18 +360,28 @@ namespace Mono.XBuild.CommandLine {
solutionTarget.Platform
);
- string solutionConfigurationContents = "<SolutionConfiguration xmlns=\"\">";
+ StringBuilder solutionConfigurationContents = new StringBuilder ();
+ solutionConfigurationContents.Append ("<SolutionConfiguration xmlns=\"\">");
foreach (KeyValuePair<Guid, ProjectInfo> projectInfo in projectInfos) {
- foreach (KeyValuePair<TargetInfo, TargetInfo> targetInfo in projectInfo.Value.TargetMap) {
- if (solutionTarget.Configuration == targetInfo.Key.Configuration && solutionTarget.Platform == targetInfo.Key.Platform) {
- solutionConfigurationContents += string.Format ("<ProjectConfiguration Project=\"{0}\">{1}|{2}</ProjectConfiguration>",
- projectInfo.Key.ToString ("B").ToUpper (), targetInfo.Value.Configuration, targetInfo.Value.Platform);
- }
- }
+ AddProjectConfigurationItems (projectInfo.Key, projectInfo.Value, solutionTarget, solutionConfigurationContents);
}
- solutionConfigurationContents += "</SolutionConfiguration>";
+ solutionConfigurationContents.Append ("</SolutionConfiguration>");
- platformPropertyGroup.AddNewProperty ("CurrentSolutionConfigurationContents", solutionConfigurationContents);
+ platformPropertyGroup.AddNewProperty ("CurrentSolutionConfigurationContents",
+ solutionConfigurationContents.ToString ());
+ }
+ }
+
+ void AddProjectConfigurationItems (Guid guid, ProjectInfo projectInfo, TargetInfo solutionTarget,
+ StringBuilder solutionConfigurationContents)
+ {
+ foreach (KeyValuePair<TargetInfo, TargetInfo> targetInfo in projectInfo.TargetMap) {
+ if (solutionTarget.Configuration == targetInfo.Key.Configuration &&
+ solutionTarget.Platform == targetInfo.Key.Platform) {
+ solutionConfigurationContents.AppendFormat (
+ "<ProjectConfiguration Project=\"{0}\">{1}|{2}</ProjectConfiguration>",
+ guid.ToString ("B").ToUpper (), targetInfo.Value.Configuration, targetInfo.Value.Platform);
+ }
}
}
@@ -326,6 +394,11 @@ namespace Mono.XBuild.CommandLine {
BuildPropertyGroup platformPropertyGroup = p.AddNewPropertyGroup (true);
platformPropertyGroup.Condition = " '$(Platform)' == '' ";
platformPropertyGroup.AddNewProperty ("Platform", target.Platform);
+
+ // emit default for AspNetConfiguration also
+ BuildPropertyGroup aspNetConfigurationPropertyGroup = p.AddNewPropertyGroup (true);
+ aspNetConfigurationPropertyGroup.Condition = " ('$(AspNetConfiguration)' == '') ";
+ aspNetConfigurationPropertyGroup.AddNewProperty ("AspNetConfiguration", "$(Configuration)");
}
void AddWarningForMissingProjectConfiguration (Target target, string slnConfig, string slnPlatform, string projectName)
@@ -340,6 +413,224 @@ namespace Mono.XBuild.CommandLine {
}
+ // Website project methods
+
+ void AddWebsiteProperties (Project p, Dictionary<Guid, ProjectInfo> websiteProjectInfos,
+ Dictionary<Guid, ProjectInfo> projectInfos)
+ {
+ var propertyGroupByConfig = new Dictionary<string, BuildPropertyGroup> ();
+ foreach (KeyValuePair<Guid, ProjectInfo> infoPair in websiteProjectInfos) {
+ ProjectInfo info = infoPair.Value;
+ string projectGuid = infoPair.Key.ToString ();
+
+ ProjectSection section;
+ if (!info.ProjectSections.TryGetValue ("WebsiteProperties", out section)) {
+ RaiseWarning (0, String.Format ("Website project '{0}' does not have the required project section: WebsiteProperties. Ignoring project.", info.Name));
+ return;
+ }
+
+ //parse project references
+ string [] ref_guids = null;
+ string references;
+ if (section.Properties.TryGetValue ("ProjectReferences", out references)) {
+ ref_guids = references.Split (new char [] {';'}, StringSplitOptions.RemoveEmptyEntries);
+ for (int i = 0; i < ref_guids.Length; i ++) {
+ // "{guid}|foo.dll"
+ ref_guids [i] = ref_guids [i].Split ('|') [0];
+
+ Guid r_guid = new Guid (ref_guids [i]);
+ ProjectInfo ref_info;
+ if (projectInfos.TryGetValue (r_guid, out ref_info))
+ // ignore if not found
+ info.Dependencies [r_guid] = ref_info;
+ }
+ }
+
+ foreach (KeyValuePair<string, string> pair in section.Properties) {
+ //looking for -- ConfigName.AspNetCompiler.PropName
+ string [] parts = pair.Key.Split ('.');
+ if (parts.Length != 3 || String.Compare (parts [1], "AspNetCompiler") != 0)
+ continue;
+
+ string config = parts [0];
+ string propertyName = parts [2];
+
+ BuildPropertyGroup bpg;
+ if (!propertyGroupByConfig.TryGetValue (config, out bpg)) {
+ bpg = p.AddNewPropertyGroup (true);
+ bpg.Condition = String.Format (" '$(AspNetConfiguration)' == '{0}' ", config);
+ propertyGroupByConfig [config] = bpg;
+ }
+
+ bpg.AddNewProperty (String.Format ("Project_{0}_AspNet{1}", projectGuid, propertyName),
+ pair.Value);
+
+ if (!info.AspNetConfigurations.Contains (config))
+ info.AspNetConfigurations.Add (config);
+ }
+ }
+ }
+
+ // For WebSite projects
+ // The main "Build" target:
+ // 1. builds all non-website projects
+ // 2. calls target for website project
+ // - gets target path for the referenced projects
+ // - Resolves dependencies, satellites etc for the
+ // referenced project assemblies, and copies them
+ // to bin/ folder
+ void AddWebsiteTargets (Project p, Dictionary<Guid, ProjectInfo> websiteProjectInfos,
+ Dictionary<Guid, ProjectInfo> projectInfos, List<ProjectInfo>[] infosByLevel,
+ List<TargetInfo> solutionTargets)
+ {
+ foreach (ProjectInfo w_info in websiteProjectInfos.Values) {
+ // gets a linear list of dependencies
+ List<ProjectInfo> depInfos = new List<ProjectInfo> ();
+ foreach (List<ProjectInfo> pinfos in infosByLevel) {
+ foreach (ProjectInfo pinfo in pinfos)
+ if (w_info.Dependencies.ContainsKey (pinfo.Guid))
+ depInfos.Add (pinfo);
+ }
+
+ foreach (string buildTarget in new string [] {"Build", "Rebuild"})
+ AddWebsiteTarget (p, w_info, projectInfos, depInfos, solutionTargets, buildTarget);
+
+ // clean/publish are not supported for website projects
+ foreach (string buildTarget in new string [] {"Clean", "Publish"})
+ AddWebsiteUnsupportedTarget (p, w_info, depInfos, buildTarget);
+ }
+ }
+
+ void AddWebsiteTarget (Project p, ProjectInfo webProjectInfo,
+ Dictionary<Guid, ProjectInfo> projectInfos, List<ProjectInfo> depInfos,
+ List<TargetInfo> solutionTargets, string buildTarget)
+ {
+ string w_guid = webProjectInfo.Guid.ToString ().ToUpper ();
+
+ Target target = p.Targets.AddNewTarget (GetTargetNameForProject (webProjectInfo.Name, buildTarget));
+ target.Condition = "'$(CurrentSolutionConfigurationContents)' != ''";
+ target.DependsOnTargets = GetWebsiteDependsOnTarget (depInfos, buildTarget);
+
+ // this item collects all the references
+ string final_ref_item = String.Format ("Project_{0}_References{1}", w_guid,
+ buildTarget != "Build" ? "_" + buildTarget : String.Empty);
+
+ foreach (TargetInfo targetInfo in solutionTargets) {
+ int ref_num = 0;
+ foreach (ProjectInfo depInfo in depInfos) {
+ TargetInfo projectTargetInfo;
+ if (!depInfo.TargetMap.TryGetValue (targetInfo, out projectTargetInfo))
+ // Ignore, no config, so no target path
+ continue;
+
+ // GetTargetPath from the referenced project
+ AddWebsiteMSBuildTaskForReference (target, depInfo, projectTargetInfo, targetInfo,
+ final_ref_item, ref_num);
+ ref_num ++;
+ }
+ }
+
+ // resolve the references
+ AddWebsiteResolveAndCopyReferencesTasks (target, webProjectInfo, final_ref_item, w_guid);
+ }
+
+ // emits the MSBuild task to GetTargetPath for the referenced project
+ void AddWebsiteMSBuildTaskForReference (Target target, ProjectInfo depInfo, TargetInfo projectTargetInfo,
+ TargetInfo solutionTargetInfo, string final_ref_item, int ref_num)
+ {
+ BuildTask task = target.AddNewTask ("MSBuild");
+ task.SetParameterValue ("Projects", depInfo.FileName);
+ task.SetParameterValue ("Targets", "GetTargetPath");
+
+ task.SetParameterValue ("Properties", string.Format ("Configuration={0}; Platform={1}; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)", projectTargetInfo.Configuration, projectTargetInfo.Platform));
+ task.Condition = string.Format (" ('$(Configuration)' == '{0}') and ('$(Platform)' == '{1}') ", solutionTargetInfo.Configuration, solutionTargetInfo.Platform);
+
+ string ref_item = String.Format ("{0}_{1}",
+ final_ref_item, ref_num);
+
+ task.AddOutputItem ("TargetOutputs", ref_item);
+
+ task = target.AddNewTask ("CreateItem");
+ task.SetParameterValue ("Include", String.Format ("@({0})", ref_item));
+ task.SetParameterValue ("AdditionalMetadata", String.Format ("Guid={{{0}}}",
+ depInfo.Guid.ToString ().ToUpper ()));
+ task.AddOutputItem ("Include", final_ref_item);
+ }
+
+ void AddWebsiteResolveAndCopyReferencesTasks (Target target, ProjectInfo webProjectInfo,
+ string final_ref_item, string w_guid)
+ {
+ BuildTask task = target.AddNewTask ("ResolveAssemblyReference");
+ task.SetParameterValue ("Assemblies", String.Format ("@({0}->'%(FullPath)')", final_ref_item));
+ task.SetParameterValue ("TargetFrameworkDirectories", "$(TargetFrameworkPath)");
+ task.SetParameterValue ("SearchPaths", "{RawFileName};{TargetFrameworkDirectory};{GAC}");
+ task.SetParameterValue ("FindDependencies", "true");
+ task.SetParameterValue ("FindSatellites", "true");
+ task.SetParameterValue ("FindRelatedFiles", "true");
+ task.Condition = String.Format ("Exists ('%({0}.Identity)')", final_ref_item);
+
+ string copylocal_item = String.Format ("{0}_CopyLocalFiles", final_ref_item);
+ task.AddOutputItem ("CopyLocalFiles", copylocal_item);
+
+ // Copy the references
+ task = target.AddNewTask ("Copy");
+ task.SetParameterValue ("SourceFiles", String.Format ("@({0})", copylocal_item));
+ task.SetParameterValue ("DestinationFiles", String.Format (
+ "@({0}->'$(Project_{1}_AspNetPhysicalPath)\\Bin\\%(DestinationSubDirectory)%(Filename)%(Extension)')",
+ copylocal_item, w_guid));
+
+ // AspNetConfiguration, is config for the website project, useful
+ // for overriding from command line
+ StringBuilder cond = new StringBuilder ();
+ foreach (string config in webProjectInfo.AspNetConfigurations) {
+ if (cond.Length > 0)
+ cond.Append (" or ");
+ cond.AppendFormat (" ('$(AspNetConfiguration)' == '{0}') ", config);
+ }
+ task.Condition = cond.ToString ();
+
+ task = target.AddNewTask ("Message");
+ cond = new StringBuilder ();
+ foreach (string config in webProjectInfo.AspNetConfigurations) {
+ if (cond.Length > 0)
+ cond.Append (" and ");
+ cond.AppendFormat (" ('$(AspNetConfiguration)' != '{0}') ", config);
+ }
+ task.Condition = cond.ToString ();
+ task.SetParameterValue ("Text", "Skipping as the '$(AspNetConfiguration)' configuration is " +
+ "not supported by this website project.");
+ }
+
+ void AddWebsiteUnsupportedTarget (Project p, ProjectInfo webProjectInfo, List<ProjectInfo> depInfos,
+ string buildTarget)
+ {
+ Target target = p.Targets.AddNewTarget (GetTargetNameForProject (webProjectInfo.Name, buildTarget));
+ target.DependsOnTargets = GetWebsiteDependsOnTarget (depInfos, buildTarget);
+
+ BuildTask task = target.AddNewTask ("Message");
+ task.SetParameterValue ("Text", String.Format (
+ "Target '{0}' not support for website projects", buildTarget));
+ }
+
+ string GetWebsiteDependsOnTarget (List<ProjectInfo> depInfos, string buildTarget)
+ {
+ StringBuilder deps = new StringBuilder ();
+ foreach (ProjectInfo pinfo in depInfos) {
+ if (deps.Length > 0)
+ deps.Append (";");
+ deps.Append (GetTargetNameForProject (pinfo.Name, buildTarget));
+ }
+ deps.Append (";GetFrameworkPath");
+ return deps.ToString ();
+ }
+
+ void AddGetFrameworkPathTarget (Project p)
+ {
+ Target t = p.Targets.AddNewTarget ("GetFrameworkPath");
+ BuildTask task = t.AddNewTask ("GetFrameworkPath");
+ task.AddOutputProperty ("Path", "TargetFrameworkPath");
+ }
+
void AddValidateSolutionConfiguration (Project p)
{
Target t = p.Targets.AddNewTarget ("ValidateSolutionConfiguration");
@@ -359,12 +650,7 @@ namespace Mono.XBuild.CommandLine {
foreach (KeyValuePair<Guid, ProjectInfo> projectInfo in projectInfos) {
ProjectInfo project = projectInfo.Value;
foreach (string buildTarget in buildTargets) {
- string target_name = project.Name +
- (buildTarget == "Build" ? string.Empty : ":" + buildTarget);
-
- if (IsBuildTargetName (project.Name))
- target_name = "Solution:" + target_name;
-
+ string target_name = GetTargetNameForProject (project.Name, buildTarget);
Target target = p.Targets.AddNewTarget (target_name);
target.Condition = "'$(CurrentSolutionConfigurationContents)' != ''";
@@ -407,6 +693,20 @@ namespace Mono.XBuild.CommandLine {
}
}
+
+ string GetTargetNameForProject (string projectName, string buildTarget)
+ {
+ //FIXME: hack
+ projectName = projectName.Replace ("\\", "/").Replace (".", "_");
+ string target_name = projectName +
+ (buildTarget == "Build" ? string.Empty : ":" + buildTarget);
+
+ if (IsBuildTargetName (projectName))
+ target_name = "Solution:" + target_name;
+
+ return target_name;
+ }
+
bool IsBuildTargetName (string name)
{
foreach (string tgt in buildTargets)
@@ -416,9 +716,10 @@ namespace Mono.XBuild.CommandLine {
}
// returns number of levels
- int AddBuildLevels (Project p, List<TargetInfo> solutionTargets, Dictionary<Guid, ProjectInfo> projectInfos)
+ int AddBuildLevels (Project p, List<TargetInfo> solutionTargets, Dictionary<Guid, ProjectInfo> projectInfos,
+ ref List<ProjectInfo>[] infosByLevel)
{
- List<ProjectInfo>[] infosByLevel = TopologicalSort<ProjectInfo> (projectInfos.Values);
+ infosByLevel = TopologicalSort<ProjectInfo> (projectInfos.Values);
foreach (TargetInfo targetInfo in solutionTargets) {
BuildItemGroup big = p.AddNewItemGroup ();
@@ -456,15 +757,16 @@ namespace Mono.XBuild.CommandLine {
return infosByLevel.Length;
}
- void AddSolutionTargets (Project p, int num_levels)
+ void AddSolutionTargets (Project p, int num_levels, IEnumerable<ProjectInfo> websiteProjectInfos)
{
foreach (string buildTarget in buildTargets) {
Target t = p.Targets.AddNewTarget (buildTarget);
t.Condition = "'$(CurrentSolutionConfigurationContents)' != ''";
+ BuildTask task = null;
for (int i = 0; i < num_levels; i ++) {
string level_str = String.Format ("BuildLevel{0}", i);
- BuildTask task = t.AddNewTask ("MSBuild");
+ task = t.AddNewTask ("MSBuild");
task.SetParameterValue ("Condition", String.Format ("'@({0})' != ''", level_str));
task.SetParameterValue ("Projects", String.Format ("@({0})", level_str));
task.SetParameterValue ("Properties",
@@ -490,6 +792,18 @@ namespace Mono.XBuild.CommandLine {
"corresponding to the solution configuration " +
"'$(Configuration)|$(Platform)' was not found.", level_str));
}
+
+ // "build" website projects also
+ StringBuilder w_targets = new StringBuilder ();
+ foreach (ProjectInfo info in websiteProjectInfos) {
+ if (w_targets.Length > 0)
+ w_targets.Append (";");
+ w_targets.Append (GetTargetNameForProject (info.Name, buildTarget));
+ }
+
+ task = t.AddNewTask ("CallTarget");
+ task.SetParameterValue ("Targets", w_targets.ToString ());
+ task.SetParameterValue ("RunEachTargetSeparately", "true");
}
}
diff --git a/mcs/tools/xbuild/xbuild/Microsoft.Common.targets b/mcs/tools/xbuild/xbuild/Microsoft.Common.targets
index e182babfa60..b256b4854f9 100644
--- a/mcs/tools/xbuild/xbuild/Microsoft.Common.targets
+++ b/mcs/tools/xbuild/xbuild/Microsoft.Common.targets
@@ -205,7 +205,6 @@
<PropertyGroup>
<BuildDependsOn>
- _ValidateEssentialProperties;
BeforeBuild;
CoreBuild;
AfterBuild