本文整理汇总了C#中Microsoft.Build.BuildEngine.Project.GetConditionedPropertyValues方法的典型用法代码示例。如果您正苦于以下问题:C# Project.GetConditionedPropertyValues方法的具体用法?C# Project.GetConditionedPropertyValues怎么用?C# Project.GetConditionedPropertyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Build.BuildEngine.Project
的用法示例。
在下文中一共展示了Project.GetConditionedPropertyValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModifyPersistedImportedPropertyGroupCondition
public void ModifyPersistedImportedPropertyGroupCondition()
{
// Create temp files on disk for the main project file and the imported project file.
string importedProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<PropertyGroup Condition=`'$(Configuration)' == 'Config1'`>
<Prop>FromUserFile1</Prop>
</PropertyGroup>
<PropertyGroup Condition=`'$(Configuration)' == 'Config2'`>
<Prop>FromUserFile2</Prop>
</PropertyGroup>
</Project>
");
string mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<Import Project=`{0}`/>
</Project>
", importedProjFilename);
try
{
// Load the two projects using the MSBuild object model.
Project mainProj = new Project(new Engine(@"c:\"));
Project importedProj = new Project(mainProj.ParentEngine);
mainProj.Load(mainProjFilename);
importedProj.Load(importedProjFilename);
foreach (BuildPropertyGroup bpg in mainProj.PropertyGroups)
{
if (bpg.Condition == "'$(Configuration)' == 'Config2'")
{
bpg.SetImportedPropertyGroupCondition("'$(Configuration)' == 'NewConfig'");
}
}
string[] configs = mainProj.GetConditionedPropertyValues("Configuration");
Assertion.AssertEquals(2, configs.Length);
Assertion.Assert(configs[0] == "Config1" || configs[1] == "Config1");
Assertion.Assert(configs[0] == "NewConfig" || configs[1] == "NewConfig");
}
finally
{
File.Delete(mainProjFilename);
File.Delete(importedProjFilename);
}
}
示例2: RemovePersistedImportedPropertyGroupMatchingCondition
public void RemovePersistedImportedPropertyGroupMatchingCondition()
{
// Create temp files on disk for the main project file and the imported project file.
string importedProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<PropertyGroup Condition=`'$(Configuration)' == 'Config1'`>
<Prop>FromUserFile1</Prop>
</PropertyGroup>
<PropertyGroup Condition=`'$(Configuration)' == 'Config2'`>
<Prop>FromUserFile2</Prop>
</PropertyGroup>
<PropertyGroup Condition=`'$(Configuration)' == 'Test'`>
<Prop>FromUserFileTest</Prop>
</PropertyGroup>
</Project>
");
string mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<Import Project=`{0}`/>
</Project>
", importedProjFilename);
try
{
// Load the two projects using the MSBuild object model.
Project mainProj = new Project(new Engine(@"c:\"));
Project importedProj = new Project(mainProj.ParentEngine);
mainProj.Load(mainProjFilename);
importedProj.Load(importedProjFilename);
mainProj.RemovePropertyGroupsWithMatchingCondition("'$(Configuration)' == 'Test'", true /* include imported */);
importedProj.RemovePropertyGroupsWithMatchingCondition("'$(Configuration)' == 'Test'", true /* include imported */);
string[] configs = mainProj.GetConditionedPropertyValues("Configuration");
Assertion.AssertEquals(2, configs.Length);
Assertion.Assert(configs[0] == "Config1" || configs[1] == "Config1");
Assertion.Assert(configs[0] == "Config2" || configs[1] == "Config2");
}
finally
{
File.Delete(mainProjFilename);
File.Delete(importedProjFilename);
}
}
示例3: RemoveImportedPropertyGroupMatchingCondition
public void RemoveImportedPropertyGroupMatchingCondition()
{
// Create temp files on disk for the main project file and the imported project file.
string importedProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
</Project>
");
string mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
<Import Project=`{0}`/>
</Project>
", importedProjFilename);
try
{
// Load the two projects using the MSBuild object model.
Project mainProj = new Project(new Engine(@"c:\"));
Project importedProj = new Project(mainProj.ParentEngine);
mainProj.Load(mainProjFilename);
importedProj.Load(importedProjFilename);
string configCondition1 = "'$(Configuration)' == 'Config1'";
string configCondition2 = "'$(Configuration)' == 'Config2'";
string configTestCondition = "'$(Configuration)' == 'Test'";
// Add same property to imported user file
mainProj.SetImportedProperty("Prop", "FromUserFile",
configCondition1, importedProj, PropertyPosition.UseExistingOrCreateAfterLastImport);
mainProj.SetImportedProperty("Prop", "FromUserFile",
configCondition2, importedProj, PropertyPosition.UseExistingOrCreateAfterLastImport);
mainProj.SetImportedProperty("Prop", "FromUserFile",
configTestCondition, importedProj, PropertyPosition.UseExistingOrCreateAfterLastImport);
mainProj.RemovePropertyGroupsWithMatchingCondition(configTestCondition, true /* include imported */);
importedProj.RemovePropertyGroupsWithMatchingCondition(configTestCondition, true /* include imported */);
string[] configs = mainProj.GetConditionedPropertyValues("Configuration");
Assertion.AssertEquals(2, configs.Length);
Assertion.Assert(configs[0] == "Config1" || configs[1] == "Config1");
Assertion.Assert(configs[0] == "Config2" || configs[1] == "Config2");
}
finally
{
File.Delete(mainProjFilename);
File.Delete(importedProjFilename);
}
}
示例4: GetConditionedPropertyValues_Missing
public void GetConditionedPropertyValues_Missing()
{
Project p = new Project();
string[] values = p.GetConditionedPropertyValues("doesnotExist");
Assertion.AssertEquals(0, values.Length);
}
示例5: GetConditionedPropertyValues_EmptyString
public void GetConditionedPropertyValues_EmptyString()
{
Project p = new Project();
string[] values = p.GetConditionedPropertyValues(String.Empty);
Assertion.AssertEquals(0, values.Length);
}
示例6: GetConditionedPropertyValues_Null
public void GetConditionedPropertyValues_Null()
{
Project p = new Project();
string[] values = p.GetConditionedPropertyValues(null);
}