internal override void ReadChildElement (MSBuildXmlReader reader)
		{
			var item = new MSBuildItem ();
			item.ParentNode = this;
			item.Read (reader);
			ChildNodes = ChildNodes.Add (item);
		}
		public MSBuildItem AddNewItem (string name, string include)
		{
			AssertCanModify ();
			var it = new MSBuildItem (name);
			it.Include = include;
			AddItem (it);
			return it;
		}
		internal void RemoveItem (MSBuildItem item)
		{
			AssertCanModify ();
			if (ChildNodes.Contains (item)) {
				item.RemoveIndent ();
				ChildNodes = ChildNodes.Remove (item);
				NotifyChanged ();
			}
		}
		public void AddItem (MSBuildItem item)
		{
			AssertCanModify ();
			item.ParentNode = this;
			ChildNodes = ChildNodes.Add (item);
			item.ResetIndent (false);
			if (ParentProject != null)
				ParentProject.NotifyChanged ();
		}
Пример #5
0
        public void AddItem(MSBuildItem item, MSBuildItem beforeItem)
        {
            AssertCanModify();
            item.ParentNode = this;

            int i;

            if (beforeItem != null && (i = ChildNodes.IndexOf(beforeItem)) != -1)
            {
                ChildNodes = ChildNodes.Insert(i, item);
            }
            else
            {
                ChildNodes = ChildNodes.Add(item);
            }

            item.ResetIndent(false);
            if (ParentProject != null)
            {
                ParentProject.NotifyChanged();
            }
        }
Пример #6
0
        MSBuildItemGroup FindBestGroupForItem(MSBuildItem newItem)
        {
            string           groupId = GetBestGroupId(newItem);
            MSBuildItemGroup group;

            if (bestGroups == null)
            {
                bestGroups = new Dictionary <string, MSBuildItemGroup> ();
            }
            else
            {
                if (bestGroups.TryGetValue(groupId, out group))
                {
                    return(group);
                }
            }

            MSBuildItemGroup insertBefore = null;

            foreach (MSBuildItemGroup grp in ItemGroups)
            {
                foreach (MSBuildItem it in grp.Items)
                {
                    if (ShouldAddItemToGroup(it, newItem))
                    {
                        bestGroups [groupId] = grp;
                        return(grp);
                    }
                    else if (insertBefore == null && ShouldInsertItemGroupBefore(it, newItem))
                    {
                        insertBefore = grp;
                    }
                }
            }
            group = AddNewItemGroup(insertBefore);
            bestGroups [groupId] = group;
            return(group);
        }
Пример #7
0
		public void AddItem (MSBuildItem it)
		{
			if (string.IsNullOrEmpty (it.Name))
				throw new InvalidOperationException ("Item doesn't have a name");
			MSBuildItemGroup grp = FindBestGroupForItem (it.Name);
			grp.AddItem (it);
		}
Пример #8
0
		public MSBuildItem CreateItem (string name, string include)
		{
			var bitem = new MSBuildItem (name);
			bitem.Include = include;
			return bitem;
		}
Пример #9
0
		MSBuildItemEvaluated Evaluate (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item)
		{
			return CreateEvaluatedItem (context, project, project.Project, item, context.EvaluateString (item.Include));
		}
Пример #10
0
		static MSBuildItemEvaluated CreateEvaluatedItem (MSBuildEvaluationContext context, ProjectInfo pinfo, MSBuildProject project, MSBuildItem sourceItem, string include)
		{
			var it = new MSBuildItemEvaluated (project, sourceItem.Name, sourceItem.Include, include);
			var md = new Dictionary<string,IMSBuildPropertyEvaluated> ();
			foreach (var c in sourceItem.Metadata.GetProperties ()) {
				if (string.IsNullOrEmpty (c.Condition) || SafeParseAndEvaluate (pinfo, context, c.Condition, true))
					md [c.Name] = new MSBuildPropertyEvaluated (project, c.Name, c.Value, context.EvaluateString (c.Value));
			}
			((MSBuildPropertyGroupEvaluated)it.Metadata).SetProperties (md);
			it.SourceItem = sourceItem;
			it.Condition = sourceItem.Condition;
			return it;
		}
		static MSBuildItemEvaluated CreateEvaluatedItem (MSBuildEvaluationContext context, MSBuildProject project, MSBuildItem sourceItem, string include)
		{
			var it = new MSBuildItemEvaluated (project, sourceItem.Name, sourceItem.Include, include);
			var md = new Dictionary<string,MSBuildPropertyEvaluated> ();
			foreach (var c in sourceItem.Metadata.GetProperties ()) {
				md [c.Name] = new MSBuildPropertyEvaluated (project, c.Name, c.Value, context.EvaluateString (c.Value));
			}
			((MSBuildPropertyGroupEvaluated)it.Metadata).SetProperties (md);
			it.SourceItem = sourceItem;
			it.Condition = sourceItem.Condition;
			return it;
		}
Пример #12
0
		static void AddItem (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item, MSBuildItemEvaluated it, string include, Regex excludeRegex, bool trueCond)
		{
			// Don't add the result from any item that has an empty include. MSBuild never returns those.
			if (include == string.Empty)
				return;
			
			if (IsIncludeTransform (include)) {
				// This is a transform
				List<MSBuildItemEvaluated> evalItems;
				var transformExp = include.Substring (2, include.Length - 3);
				if (ExecuteTransform (project, context, item, transformExp, out evalItems)) {
					foreach (var newItem in evalItems) {
						project.EvaluatedItemsIgnoringCondition.Add (newItem);
						if (trueCond)
							project.EvaluatedItems.Add (newItem);
					}
				}
			} else if (include.IndexOf ('*') != -1) {
				var path = include;
				if (path == "**" || path.EndsWith ("\\**"))
					path = path + "/*";
				var subpath = path.Split ('\\');
				foreach (var eit in ExpandWildcardFilePath (project, project.Project, context, item, project.Project.BaseDirectory, FilePath.Null, false, subpath, 0)) {
					if (excludeRegex != null && excludeRegex.IsMatch (eit.Include))
						continue;
					project.EvaluatedItemsIgnoringCondition.Add (eit);
					if (trueCond)
						project.EvaluatedItems.Add (eit);
				}
			} else if (include != it.Include) {
				if (excludeRegex != null && excludeRegex.IsMatch (include))
					return;
				it = CreateEvaluatedItem (context, project, project.Project, item, include);
				project.EvaluatedItemsIgnoringCondition.Add (it);
				if (trueCond)
					project.EvaluatedItems.Add (it);
			} else {
				if (excludeRegex != null && excludeRegex.IsMatch (include))
					return;
				project.EvaluatedItemsIgnoringCondition.Add (it);
				if (trueCond)
					project.EvaluatedItems.Add (it);
			}
		}
Пример #13
0
 internal abstract IEnumerable <MSBuildItem> FindUpdateGlobItemsIncludingFile(object projectInstance, string include, MSBuildItem globItem);
Пример #14
0
        static MSBuildItemEvaluated CreateEvaluatedItem(MSBuildEvaluationContext context, ProjectInfo pinfo, MSBuildProject project, MSBuildItem sourceItem, string include)
        {
            var it = new MSBuildItemEvaluated(project, sourceItem.Name, sourceItem.Include, include);
            var md = new Dictionary <string, IMSBuildPropertyEvaluated> ();

            foreach (var c in sourceItem.Metadata.GetProperties())
            {
                if (string.IsNullOrEmpty(c.Condition) || SafeParseAndEvaluate(pinfo, context, c.Condition, true))
                {
                    md [c.Name] = new MSBuildPropertyEvaluated(project, c.Name, c.Value, context.EvaluateString(c.Value));
                }
            }
            ((MSBuildPropertyGroupEvaluated)it.Metadata).SetProperties(md);
            it.SourceItem = sourceItem;
            it.Condition  = sourceItem.Condition;
            return(it);
        }
		void AddPackagingTargetsImport (MSBuildProject msproject)
		{
			// Create dummy new msbuild object to ensure import is added as last child.
			var insertBefore = new MSBuildItem ();
			msproject.AddNewImport (
				@"$(NuGetAuthoringPath)\NuGet.Packaging.Authoring.targets",
				@"Exists('$(NuGetAuthoringPath)\NuGet.Packaging.Authoring.targets')",
				insertBefore);
		}
Пример #16
0
 internal override IEnumerable <MSBuildItem> FindUpdateGlobItemsIncludingFile(object projectInstance, string include, MSBuildItem globItem)
 {
     throw new NotImplementedException();
 }
Пример #17
0
		internal protected virtual void Write (Project project, MSBuildItem buildItem)
		{
			buildItem.Condition = Condition;
			buildItem.Metadata.WriteObjectProperties (this, GetType(), true);

			if (metadata != null) {
				metadata.SetProject (buildItem.ParentProject);
				foreach (var prop in metadata.GetProperties ()) {
					// Use the UnevaluatedValue because if the property has changed, UnevaluatedValue will contain
					// the new value, and if not, it will contain the old unevaluated value
					buildItem.Metadata.SetValue (prop.Name, prop.UnevaluatedValue);
				}
			}
		}
Пример #18
0
		static bool ExecuteTransform (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item, string transformExp, out List<MSBuildItemEvaluated> items)
		{
			bool ignoreMetadata = false;

			items = new List<MSBuildItemEvaluated> ();
			string itemName, expression, itemFunction; object [] itemFunctionArgs;

			// This call parses the transforms and extracts: the name of the item list to transform, the whole transform expression (or null if there isn't). If the expression can be
			// parsed as an item funciton, then it returns the function name and the list of arguments. Otherwise those parameters are null.
			if (!ParseTransformExpression (context, transformExp, out itemName, out expression, out itemFunction, out itemFunctionArgs))
				return false;

			// Get the items mathing the referenced item list
			var transformItems = project.EvaluatedItems.Where (i => i.Name == itemName).ToArray ();

			if (itemFunction != null) {
				// First of all, try to execute the function as a summary function, that is, a function that returns a single value for
				// the whole list (such as Count).
				// After that, try executing as a list transformation function: a function that changes the order or filters out items from the list.

				string result;
				if (ExecuteSummaryItemFunction (transformItems, itemFunction, itemFunctionArgs, out result)) {
					// The item function returns a value. Just create an item with that value
					var newItem = new MSBuildItemEvaluated (project.Project, item.Name, item.Include, result);
					project.EvaluatedItemsIgnoringCondition.Add (newItem);
					items.Add (newItem);
					return true;
				} else if (ExecuteTransformItemListFunction (ref transformItems, itemFunction, itemFunctionArgs, out ignoreMetadata)) {
					expression = null;
					itemFunction = null;
				}
			}

			foreach (var eit in transformItems) {
				// Some item functions cause the erasure of metadata. Take that into account now.
				context.SetItemContext (eit.Include, null, ignoreMetadata || item == null ? null : eit.Metadata);
				try {
					// If there is a function that transforms the include of the item, it needs to be applied now. Otherwise just use the transform expression
					// as include, or the transformed item include if there is no expression.

					string evaluatedInclude; bool skip;
					if (itemFunction != null && ExecuteTransformIncludeItemFunction (context, eit, itemFunction, itemFunctionArgs, out evaluatedInclude, out skip)) {
						if (skip) continue;
					} else if (expression != null)
						evaluatedInclude = context.EvaluateString (expression);
					else
						evaluatedInclude = eit.Include;

					var newItem = new MSBuildItemEvaluated (project.Project, item.Name, item.Include, evaluatedInclude);
					if (!ignoreMetadata) {
						var md = new Dictionary<string, IMSBuildPropertyEvaluated> ();
						// Add metadata from the evaluated item
						var col = (MSBuildPropertyGroupEvaluated)eit.Metadata;
						foreach (var p in col.GetRegisteredProperties ()) {
							md [p.Name] = new MSBuildPropertyEvaluated (project.Project, p.Name, p.UnevaluatedValue, p.Value);
						}
						// Now override metadata from the new item definition
						foreach (var c in item.Metadata.GetProperties ()) {
							if (string.IsNullOrEmpty (c.Condition) || SafeParseAndEvaluate (project, context, c.Condition, true))
								md [c.Name] = new MSBuildPropertyEvaluated (project.Project, c.Name, c.Value, context.EvaluateString (c.Value));
						}
						((MSBuildPropertyGroupEvaluated)newItem.Metadata).SetProperties (md);
					}
					newItem.SourceItem = item;
					newItem.Condition = item.Condition;
					items.Add (newItem);
				} finally {
					context.ClearItemContext ();
				}
			}
			return true;
		}
Пример #19
0
		public void RemoveItem (MSBuildItem item, bool removeEmptyParentGroup = true)
		{
			AssertCanModify ();
			if (item.ParentGroup != null) {
				item.RemoveIndent ();
				var g = item.ParentGroup;
				g.RemoveItem (item);
				if (removeEmptyParentGroup && !g.Items.Any ()) {
					Remove (g);
					if (bestGroups != null)
						bestGroups.Remove (item.Name);
				}
			}
		}
Пример #20
0
 static bool ShouldAddItemToGroup(MSBuildItem existingItem, MSBuildItem newItem)
 {
     return(existingItem.Name == newItem.Name &&
            existingItem.IsRemove == newItem.IsRemove &&
            existingItem.IsUpdate == newItem.IsUpdate);
 }
Пример #21
0
        static IEnumerable <MSBuildItemEvaluated> ExpandWildcardFilePath(ProjectInfo pinfo, MSBuildProject project, MSBuildEvaluationContext context, MSBuildItem sourceItem, FilePath basePath, FilePath baseRecursiveDir, bool recursive, string[] filePath, int index)
        {
            var res = Enumerable.Empty <MSBuildItemEvaluated> ();

            if (index >= filePath.Length)
            {
                return(res);
            }

            var path = filePath [index];

            if (path == "..")
            {
                return(ExpandWildcardFilePath(pinfo, project, context, sourceItem, basePath.ParentDirectory, baseRecursiveDir, recursive, filePath, index + 1));
            }

            if (path == ".")
            {
                return(ExpandWildcardFilePath(pinfo, project, context, sourceItem, basePath, baseRecursiveDir, recursive, filePath, index + 1));
            }

            if (!Directory.Exists(basePath))
            {
                return(res);
            }

            if (path == "**")
            {
                // if this is the last component of the path, there isn't any file specifier, so there is no possible match
                if (index + 1 >= filePath.Length)
                {
                    return(res);
                }

                // If baseRecursiveDir has already been set, don't overwrite it.
                if (baseRecursiveDir.IsNullOrEmpty)
                {
                    baseRecursiveDir = basePath;
                }

                return(ExpandWildcardFilePath(pinfo, project, context, sourceItem, basePath, baseRecursiveDir, true, filePath, index + 1));
            }

            if (recursive)
            {
                // Recursive search. Try to match the remaining subpath in all subdirectories.
                foreach (var dir in Directory.GetDirectories(basePath))
                {
                    res = res.Concat(ExpandWildcardFilePath(pinfo, project, context, sourceItem, dir, baseRecursiveDir, true, filePath, index));
                }
            }

            if (index == filePath.Length - 1)
            {
                // Last path component. It has to be a file specifier.
                string baseDir = basePath.ToRelative(project.BaseDirectory).ToString().Replace('/', '\\');
                if (baseDir == ".")
                {
                    baseDir = "";
                }
                else if (!baseDir.EndsWith("\\", StringComparison.Ordinal))
                {
                    baseDir += '\\';
                }
                var recursiveDir = baseRecursiveDir.IsNullOrEmpty ? FilePath.Null : basePath.ToRelative(baseRecursiveDir);
                res = res.Concat(Directory.GetFiles(basePath, path).Select(f => {
                    context.SetItemContext(f, recursiveDir);
                    var ev = baseDir + Path.GetFileName(f);
                    return(CreateEvaluatedItem(context, pinfo, project, sourceItem, ev));
                }));
            }
            else
            {
                // Directory specifier
                // Look for matching directories.
                // The search here is non-recursive, not matter what the 'recursive' parameter says, since we are trying to match a subpath.
                // The recursive search is done below.

                if (path.IndexOfAny(wildcards) != -1)
                {
                    foreach (var dir in Directory.GetDirectories(basePath, path))
                    {
                        res = res.Concat(ExpandWildcardFilePath(pinfo, project, context, sourceItem, dir, baseRecursiveDir, false, filePath, index + 1));
                    }
                }
                else
                {
                    res = res.Concat(ExpandWildcardFilePath(pinfo, project, context, sourceItem, basePath.Combine(path), baseRecursiveDir, false, filePath, index + 1));
                }
            }

            return(res);
        }
		internal protected override void Write (Project project, MSBuildItem buildItem)
		{
			if (string.IsNullOrEmpty (Include))
				Include = MSBuildProjectService.ToMSBuildPath (project.ItemDirectory, Path);
			base.Write (project, buildItem);
		}
Пример #23
0
 MSBuildItemEvaluated Evaluate(ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item)
 {
     return(CreateEvaluatedItem(context, project, project.Project, item, context.EvaluateString(item.Include)));
 }
Пример #24
0
		internal protected override void Write (Project project, MSBuildItem buildItem)
		{
			// If the project is not supported, don't try to update any metadata of the property,
			// just leave what was read
			if (OwnerProject.IsUnsupportedProject)
				return;

			base.Write (project, buildItem);

			if (ReferenceType == ReferenceType.Assembly) {
				if (!hasBeenRead && !HintPath.IsNullOrEmpty)
					buildItem.Metadata.SetValue ("HintPath", HintPath);

				buildItem.Metadata.SetValue ("SpecificVersion", SpecificVersion || !ReferenceStringHasVersion (Include), true);
			}
			else if (ReferenceType == ReferenceType.Package) {
				buildItem.Metadata.SetValue ("SpecificVersion", SpecificVersion || !ReferenceStringHasVersion (Include), true);

				//RequiredTargetFramework is undocumented, maybe only a hint for VS. Only seems to be used for .NETFramework
				var dnp = OwnerProject as DotNetProject;
				IList supportedFrameworks = project.FileFormat.SupportedFrameworks;
				if (supportedFrameworks != null && dnp != null && Package != null
					&& dnp.TargetFramework.Id.Identifier == TargetFrameworkMoniker.ID_NET_FRAMEWORK
					&& Package.IsFrameworkPackage && supportedFrameworks.Contains (Package.TargetFramework)
					&& Package.TargetFramework.Version != "2.0" && supportedFrameworks.Count > 1)
				{
					TargetFramework fx = Runtime.SystemAssemblyService.GetTargetFramework (Package.TargetFramework);
					buildItem.Metadata.SetValue ("RequiredTargetFramework", fx.Id.Version);
				} else {
					buildItem.Metadata.RemoveProperty ("RequiredTargetFramework");
				}
			}
			else if (ReferenceType == ReferenceType.Project) {
				Project refProj = OwnerProject.ParentSolution != null ? ResolveProject (OwnerProject.ParentSolution) : null;
				if (refProj != null) {
					buildItem.Metadata.SetValue ("Project", refProj.ItemId, preserveExistingCase:true);
					buildItem.Metadata.SetValue ("Name", refProj.Name);
					buildItem.Metadata.SetValue ("ReferenceOutputAssembly", ReferenceOutputAssembly, true);
				}
			}

			buildItem.Metadata.SetValue ("Private", LocalCopy, DefaultLocalCopy);
		}
 internal IEnumerable <MSBuildItem> FindUpdateGlobItemsIncludingFile(string include, MSBuildItem globItem)
 {
     return(engine?.FindUpdateGlobItemsIncludingFile(projectInstance, include, globItem));
 }
Пример #26
0
		static void AddItem (ProjectInfo project, MSBuildEvaluationContext context, MSBuildItem item, MSBuildItemEvaluated it, string include, Regex excludeRegex, bool trueCond)
		{
			if (include.IndexOf ('*') != -1) {
				var path = include;
				if (path == "**" || path.EndsWith ("\\**"))
					path = path + "/*";
				var subpath = path.Split ('\\');
				foreach (var eit in ExpandWildcardFilePath (project, project.Project, context, item, project.Project.BaseDirectory, FilePath.Null, false, subpath, 0)) {
					if (excludeRegex != null && excludeRegex.IsMatch (eit.Include))
						continue;
					project.EvaluatedItemsIgnoringCondition.Add (eit);
					if (trueCond)
						project.EvaluatedItems.Add (eit);
				}
			}
			else if (include != it.Include) {
				if (excludeRegex != null && excludeRegex.IsMatch (include))
					return;
				it = CreateEvaluatedItem (context, project, project.Project, item, include);
				project.EvaluatedItemsIgnoringCondition.Add (it);
				if (trueCond)
					project.EvaluatedItems.Add (it);
			}
			else {
				if (excludeRegex != null && excludeRegex.IsMatch (include))
					return;
				project.EvaluatedItemsIgnoringCondition.Add (it);
				if (trueCond)
					project.EvaluatedItems.Add (it);
			}
		}
Пример #27
0
 public void AddItem(MSBuildItem it)
 {
     AddItem(it, null);
 }
Пример #28
0
		static IEnumerable<MSBuildItemEvaluated> ExpandWildcardFilePath (ProjectInfo pinfo, MSBuildProject project, MSBuildEvaluationContext context, MSBuildItem sourceItem, FilePath basePath, FilePath baseRecursiveDir, bool recursive, string[] filePath, int index)
		{
			var res = Enumerable.Empty<MSBuildItemEvaluated> ();

			if (index >= filePath.Length)
				return res;

			var path = filePath [index];

			if (path == "..")
				return ExpandWildcardFilePath (pinfo, project, context, sourceItem, basePath.ParentDirectory, baseRecursiveDir, recursive, filePath, index + 1);
			
			if (path == ".")
				return ExpandWildcardFilePath (pinfo, project, context, sourceItem, basePath, baseRecursiveDir, recursive, filePath, index + 1);

			if (!Directory.Exists (basePath))
				return res;

			if (path == "**") {
				// if this is the last component of the path, there isn't any file specifier, so there is no possible match
				if (index + 1 >= filePath.Length)
					return res;
				
				// If baseRecursiveDir has already been set, don't overwrite it.
				if (baseRecursiveDir.IsNullOrEmpty)
					baseRecursiveDir = basePath;
				
				return ExpandWildcardFilePath (pinfo, project, context, sourceItem, basePath, baseRecursiveDir, true, filePath, index + 1);
			}

			if (recursive) {
				// Recursive search. Try to match the remaining subpath in all subdirectories.
				foreach (var dir in Directory.GetDirectories (basePath))
					res = res.Concat (ExpandWildcardFilePath (pinfo, project, context, sourceItem, dir, baseRecursiveDir, true, filePath, index));
			}

			if (index == filePath.Length - 1) {
				// Last path component. It has to be a file specifier.
				string baseDir = basePath.ToRelative (project.BaseDirectory).ToString().Replace ('/','\\');
				if (baseDir == ".")
					baseDir = "";
				else if (!baseDir.EndsWith ("\\", StringComparison.Ordinal))
					baseDir += '\\';
				var recursiveDir = baseRecursiveDir.IsNullOrEmpty ? FilePath.Null : basePath.ToRelative (baseRecursiveDir);
				res = res.Concat (Directory.GetFiles (basePath, path).Select (f => {
					context.SetItemContext (f, recursiveDir);
					var ev = baseDir + Path.GetFileName (f);
					return CreateEvaluatedItem (context, pinfo, project, sourceItem, ev);
				}));
			}
			else {
				// Directory specifier
				// Look for matching directories.
				// The search here is non-recursive, not matter what the 'recursive' parameter says, since we are trying to match a subpath.
				// The recursive search is done below.

				if (path.IndexOfAny (wildcards) != -1) {
					foreach (var dir in Directory.GetDirectories (basePath, path))
						res = res.Concat (ExpandWildcardFilePath (pinfo, project, context, sourceItem, dir, baseRecursiveDir, false, filePath, index + 1));
				} else
					res = res.Concat (ExpandWildcardFilePath (pinfo, project, context, sourceItem, basePath.Combine (path), baseRecursiveDir, false, filePath, index + 1));
			}

			return res;
		}
Пример #29
0
        internal IEnumerable <MSBuildItem> FindUpdateGlobItemsIncludingFile(string include, MSBuildItem globItem)
        {
            var currentEngine          = engine;
            var currentProjectInstance = projectInstance;

            if (currentEngine == null || currentProjectInstance == null)
            {
                return(null);
            }
            return(currentEngine.FindUpdateGlobItemsIncludingFile(currentProjectInstance, include, globItem));
        }
Пример #30
0
		internal protected override void Write (Project project, MSBuildItem buildItem)
		{
			base.Write (project, buildItem);

			buildItem.Metadata.SetValue ("DependentUpon", DependsOn, FilePath.Empty, relativeToPath:FilePath.ParentDirectory);
			buildItem.Metadata.SetValue ("SubType", ContentType, "");
			buildItem.Metadata.SetValue ("Generator", Generator, "");
			buildItem.Metadata.SetValue ("CustomToolNamespace", CustomToolNamespace, "");
			buildItem.Metadata.SetValue ("LastGenOutput", LastGenOutput, "");
			buildItem.Metadata.SetValue ("Link", Link, FilePath.Empty, relativeToProject:false);
			buildItem.Metadata.SetValue ("CopyToOutputDirectory", CopyToOutputDirectory.ToString (), "None");
			buildItem.Metadata.SetValue ("Visible", Visible, true);

			var resId = ResourceId;

			// For EmbeddedResource, emit LogicalName only when it does not match the default msbuild resource Id
			if (project is DotNetProject && BuildAction == MonoDevelop.Projects.BuildAction.EmbeddedResource && ((DotNetProject)project).GetDefaultMSBuildResourceId (this) == resId)
				resId = "";

			buildItem.Metadata.SetValue ("LogicalName", resId, "");
		}