本文整理汇总了C#中Microsoft.Build.Construction.ProjectRootElement.AddPropertyGroup方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectRootElement.AddPropertyGroup方法的具体用法?C# ProjectRootElement.AddPropertyGroup怎么用?C# ProjectRootElement.AddPropertyGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.Construction.ProjectRootElement
的用法示例。
在下文中一共展示了ProjectRootElement.AddPropertyGroup方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpgradeProject
protected override void UpgradeProject(ref ProjectRootElement projectXml, ref ProjectRootElement userProjectXml, Action<__VSUL_ERRORLEVEL, string> log) {
var envVarsProp = projectXml.Properties.FirstOrDefault(p => p.Name == NodejsConstants.EnvironmentVariables);
if (envVarsProp != null) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, NodejsConstants.Environment, envVarsProp.Value.Replace(";", "\r\n"));
envVarsProp.Parent.RemoveChild(envVarsProp);
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedEnvironmentVariables));
}
}
示例2: AddElement
public void AddElement(ProjectRootElement root)
{
var ret = root.AddPropertyGroup ();
ret.Condition = Condition;
foreach (var p in Properties) {
var value = p.Value ();
if (string.IsNullOrWhiteSpace (value))
continue;
var pe = ret.AddProperty (p.Name, value);
pe.Condition = p.Condition;
}
}
示例3: Process
public override void Process(
ProjectRootElement project,
Dictionary<string, ProjectPropertyGroupElement> groups
) {
ProjectPropertyGroupElement imports;
if (!groups.TryGetValue("Imports", out imports)) {
imports = project.AddPropertyGroup();
}
AddOrSetProperty(imports, "PtvsTargetsFile", @"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets");
project.AddImport("$(PtvsTargetsFile)").Condition = "Exists($(PtvsTargetsFile))";
project.AddImport(@"$(MSBuildToolsPath)\Microsoft.Common.targets").Condition = "!Exists($(PtvsTargetsFile))";
}
示例4: CreatePropertyGroup
static ProjectPropertyGroupElement CreatePropertyGroup(ProjectRootElement root,
string targetFrameworkVersion,
string condition, string platform_condition,
string configuration, string platform, bool unsafeMode,
string assemblyName)
{
ProjectPropertyGroupElement group = root.AddPropertyGroup();
var config = group.AddProperty("Configuration", configuration);
config.Condition = condition;
var platform_ = group.AddProperty("Platform", platform);
platform_.Condition = platform_condition;
group.AddProperty("SchemaVersion", "2.0");
group.AddProperty("OutputType", "Library");
group.AddProperty("TargetFrameworkVersion", targetFrameworkVersion);
group.AddProperty("FileAlignment", "512");
group.AddProperty("AssemblyName", assemblyName);
return group;
}
示例5: CreatePropertyGroupChoice
static ProjectPropertyGroupElement CreatePropertyGroupChoice(ProjectRootElement root,
string condition,
bool unsafeMode, string outputPath, bool optimize,
bool debugSymbol, string debugType, string constants
)
{
ProjectPropertyGroupElement group = root.AddPropertyGroup();
group.Condition = condition;
if (unsafeMode)
{
group.AddProperty("AllowUnsafeBlocks", "true");
}
group.AddProperty("ErrorReport", "prompt");
group.AddProperty("WarningLevel", "4");
group.AddProperty("OutputPath", outputPath); //,eg @"bin\Debug\"
group.AddProperty("Optimize", optimize ? "true" : "false");
group.AddProperty("DebugType", debugType);
if (debugSymbol)
{
group.AddProperty("DebugSymbols", "true");
}
group.AddProperty("DefineConstants", constants); //eg DEBUG; TRACE
return group;
}
示例6: AddNewPropertyGroup
ProjectPropertyGroupElement AddNewPropertyGroup(ProjectRootElement targetProject, PropertyPosition position)
{
if (position == PropertyPosition.UseExistingOrCreateAfterLastImport) {
var propertyGroup = targetProject.CreatePropertyGroupElement();
targetProject.AppendChild(propertyGroup);
return propertyGroup;
}
return targetProject.AddPropertyGroup();
}
示例7: CopyProperties
/// <summary>
/// copy properties from g into a new property group for newConfiguration and newPlatform
/// </summary>
void CopyProperties(ProjectRootElement project, ProjectPropertyGroupElement g, string newConfiguration, string newPlatform)
{
ProjectPropertyGroupElement ng = project.AddPropertyGroup();
ng.Condition = CreateCondition(newConfiguration, newPlatform);
foreach (var p in g.Properties) {
ng.AddProperty(p.Name, p.Value).Condition = p.Condition;
}
}
示例8: UpgradeProject
protected override void UpgradeProject(
ref ProjectRootElement projectXml,
ref ProjectRootElement userProjectXml,
Action<__VSUL_ERRORLEVEL, string> log
) {
Version version;
// ToolsVersion less than 4.0 (or unspecified) is not supported, so
// set it to 4.0.
if (!Version.TryParse(projectXml.ToolsVersion, out version) ||
version < new Version(4, 0)) {
projectXml.ToolsVersion = "4.0";
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedToolsVersion));
}
// Importing a targets file from 2.1 Beta
var bottleImports = projectXml.Imports.Where(p => p.Project.Equals(Ptvs21BetaBottleTargets, StringComparison.OrdinalIgnoreCase)).ToList();
var flaskImports = projectXml.Imports.Where(p => p.Project.Equals(Ptvs21BetaFlaskTargets, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var import in bottleImports.Concat(flaskImports)) {
import.Project = WebTargets;
}
if (bottleImports.Any()) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, "PythonDebugWebServerCommandArguments", "--debug $(CommandLineArguments)");
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app()");
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedBottleImports));
}
if (flaskImports.Any()) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app");
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedFlaskImports));
}
var commonPropsImports = projectXml.Imports.Where(p => p.Project.Equals(CommonProps, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var p in commonPropsImports) {
projectXml.RemoveChild(p);
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedRemoveCommonProps));
}
if (projectXml.Imports.Count == 1 && projectXml.Imports.First().Project.Equals(CommonTargets, StringComparison.OrdinalIgnoreCase)) {
projectXml.RemoveChild(projectXml.Imports.First());
var group = projectXml.AddPropertyGroup();
if (!projectXml.Properties.Any(p => p.Name == "VisualStudioVersion")) {
group.AddProperty("VisualStudioVersion", "10.0").Condition = "'$(VisualStudioVersion)' == ''";
}
group.AddProperty("PtvsTargetsFile", PtvsTargets);
projectXml.AddImport("$(PtvsTargetsFile)").Condition = "Exists($(PtvsTargetsFile))";
projectXml.AddImport(CommonTargets).Condition = "!Exists($(PtvsTargetsFile))";
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, SR.GetString(SR.UpgradedRemoveCommonTargets));
}
}
示例9: Process
public override void Process(
ProjectRootElement project,
Dictionary<string, ProjectPropertyGroupElement> groups
) {
ProjectPropertyGroupElement globals;
if (!groups.TryGetValue("Globals", out globals)) {
globals = project.AddPropertyGroup();
}
AddOrSetProperty(globals, "ProjectTypeGuids", "{789894c7-04a9-4a11-a6b5-3f4435165112};{1b580a1a-fdb3-4b32-83e1-6407eb2722e6};{349c5851-65df-11da-9384-00065b846f21};{888888a0-9f3d-457c-b088-3a5042f75d52}");
AddOrSetProperty(globals, "LaunchProvider", PythonConstants.WebLauncherName);
AddOrSetProperty(globals, "WebBrowserUrl", "http://localhost");
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app");
project.AddImport(@"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.Web.targets");
}
示例10: CopyProperties
/// <summary>
/// copy properties from g into a new property group for newConfiguration and newPlatform
/// </summary>
void CopyProperties(ProjectRootElement project, ProjectPropertyGroupElement g, ConfigurationAndPlatform newConfig)
{
ProjectPropertyGroupElement ng = project.AddPropertyGroup();
ng.Condition = newConfig.ToCondition();
foreach (var p in g.Properties) {
ng.AddProperty(p.Name, p.Value).Condition = p.Condition;
}
}
示例11: MSBuildSetProperty
void MSBuildSetProperty(ProjectRootElement targetProject, string propertyName, string newValue,
string groupCondition, PropertyPosition position,
bool treatPropertyValueAsLiteral)
{
if (treatPropertyValueAsLiteral)
newValue = MSBuildInternals.Escape(newValue);
if (groupCondition == null) {
// MSBuild uses an empty string when there's no condition, so we need to do the same
// for the comparison to succeed.
groupCondition = string.Empty;
}
foreach (var propertyGroup in targetProject.PropertyGroups) {
if (propertyGroup.Condition == groupCondition) {
foreach (var property in propertyGroup.Properties.ToList()) {
if (MSBuildInternals.PropertyNameComparer.Equals(property.Name, propertyName)) {
property.Value = newValue;
return;
}
}
}
}
foreach (var propertyGroup in targetProject.PropertyGroups) {
if (propertyGroup.Condition == groupCondition) {
propertyGroup.AddProperty(propertyName, newValue);
return;
}
}
var newGroup = targetProject.AddPropertyGroup();
newGroup.Condition = groupCondition;
newGroup.AddProperty(propertyName, newValue);
}
示例12: ProcessImportsFrom21b
private static void ProcessImportsFrom21b(ProjectRootElement projectXml, Action<__VSUL_ERRORLEVEL, string> log) {
var bottleImports = projectXml.Imports.Where(p => p.Project.Equals(Ptvs21BetaBottleTargets, StringComparison.OrdinalIgnoreCase)).ToList();
var flaskImports = projectXml.Imports.Where(p => p.Project.Equals(Ptvs21BetaFlaskTargets, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var import in bottleImports.Concat(flaskImports)) {
import.Project = WebTargets;
}
if (bottleImports.Any()) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, "PythonDebugWebServerCommandArguments", "--debug $(CommandLineArguments)");
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app()");
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedBottleImports);
}
if (flaskImports.Any()) {
var globals = projectXml.PropertyGroups.FirstOrDefault() ?? projectXml.AddPropertyGroup();
AddOrSetProperty(globals, "PythonWsgiHandler", "{StartupModule}.wsgi_app");
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedFlaskImports);
}
var commonPropsImports = projectXml.Imports.Where(p => p.Project.Equals(CommonProps, StringComparison.OrdinalIgnoreCase)).ToList();
foreach (var p in commonPropsImports) {
projectXml.RemoveChild(p);
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedRemoveCommonProps);
}
if (projectXml.Imports.Count == 1 && projectXml.Imports.First().Project.Equals(CommonTargets, StringComparison.OrdinalIgnoreCase)) {
projectXml.RemoveChild(projectXml.Imports.First());
projectXml.AddImport(PtvsTargets);
log(__VSUL_ERRORLEVEL.VSUL_INFORMATIONAL, Strings.UpgradedRemoveCommonTargets);
}
}