本文整理汇总了C#中Microsoft.Build.Construction.ProjectRootElement.AddProperty方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectRootElement.AddProperty方法的具体用法?C# ProjectRootElement.AddProperty怎么用?C# ProjectRootElement.AddProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Construction.ProjectRootElement
的用法示例。
在下文中一共展示了ProjectRootElement.AddProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddOrSetProperty
protected static void AddOrSetProperty(ProjectRootElement project, string name, string value) {
bool anySet = false;
foreach (var prop in project.Properties.Where(p => p.Name == name)) {
prop.Value = value;
anySet = true;
}
if (!anySet) {
project.AddProperty(name, value);
}
}
示例2: MSBuildBasedProject
public MSBuildBasedProject(ProjectCreateInformation information)
{
this.projectCollection = information.Solution.MSBuildProjectCollection;
this.projectFile = ProjectRootElement.Create(projectCollection);
this.userProjectFile = ProjectRootElement.Create(projectCollection);
this.ActivePlatform = information.Platform;
Name = information.ProjectName;
FileName = information.OutputProjectFileName;
projectFile.FullPath = information.OutputProjectFileName;
projectFile.ToolsVersion = "4.0";
projectFile.DefaultTargets = "Build";
userProjectFile.FullPath = information.OutputProjectFileName + ".user";
base.IdGuid = "{" + Guid.NewGuid().ToString().ToUpperInvariant() + "}";
projectFile.AddProperty(ProjectGuidPropertyName, IdGuid);
AddGuardedProperty("Configuration", "Debug");
AddGuardedProperty("Platform", information.Platform);
this.ActiveConfiguration = "Debug";
this.ActivePlatform = information.Platform;
if (information.Platform == "x86")
SetProperty(null, information.Platform, "PlatformTarget", "x86", PropertyStorageLocations.PlatformSpecific, false);
else
SetProperty(null, information.Platform, "PlatformTarget", "AnyCPU", PropertyStorageLocations.PlatformSpecific, false);
}
示例3: ConvertInMemoryToMSBuildProject
//.........这里部分代码省略.........
if (nextImport.Project.Contains(workflowOldWhidbeyTargetsPath))
{
listOfWFImportsToBeDeleted.Add(nextImport);
workflowImportsToAdd.Add(nextImport.Project.Replace(workflowOldWhidbeyTargetsPath, workflowNewTargetsPath));
removedWFWhidbeyTargets = true;
}
if (nextImport.Project.Contains(workflowOldOrcasTargetsPath))
{
listOfWFImportsToBeDeleted.Add(nextImport);
workflowImportsToAdd.Add(nextImport.Project.Replace(workflowOldOrcasTargetsPath, workflowNewTargetsPath));
}
}
// Now delete any matching imports
foreach (ProjectImportElement importToDelete in listOfWFImportsToBeDeleted)
{
this.xmakeProject.RemoveChild(importToDelete);
changedProject = true;
}
bool removedWinFXTargets = false;
foreach (ProjectImportElement importToDelete in listOfImportsToBeDeleted)
{
this.xmakeProject.RemoveChild(importToDelete);
removedWinFXTargets = true;
changedProject = true;
}
// If we removed WinFX targets this is a sparkle project and should use v3.0
if (removedWinFXTargets)
{
xmakeProject.AddProperty(XMakeProjectStrings.TargetFrameworkVersion, "v3.0");
changedProject = true;
}
//If we removed WFWhidbey imports, we should target this project to v3.0
if (removedWFWhidbeyTargets)
{
xmakeProject.AddProperty(XMakeProjectStrings.TargetFrameworkVersion, "v3.0");
changedProject = true;
}
// Re-add the workflow imports with the v4.0 targets.
foreach (string workflowImportToAdd in workflowImportsToAdd)
{
this.xmakeProject.AddImport(workflowImportToAdd);
changedProject = true;
}
// Find all the XAML files in the project and give them the custom attributes
// <Generator>MSBuild:Compile</Generator> (DevDiv Bugs bug 81222)
// <SubType>Designer</SubType> (DevDiv Bugs bug 82748)
// Find all references to old VC project files (.vcproj extension) and change the
// extension to .vcxproj instead. NOTE: we assume that the actual .vcproj -> .vcxproj
// conversion has already been / is being / will be done elsewhere.
// Dev10 Bug 557388
foreach (ProjectItemElement nextItem in xmakeProject.Items)
{
if ((!nextItem.ItemType.Equals("Reference", StringComparison.OrdinalIgnoreCase)) &&
(nextItem.Include.Trim().EndsWith(".xaml", StringComparison.OrdinalIgnoreCase)))