public void MSBuildToolsetsTest_Basic() { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets default=""2.0""> <toolset toolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v2.0.x86ret\""/> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ConfigurationSection section = config.GetSection(s_msbuildToolsets); ToolsetConfigurationSection msbuildToolsetSection = section as ToolsetConfigurationSection; Assert.Equal(msbuildToolsetSection.MSBuildOverrideTasksPath, null); Assert.Equal(msbuildToolsetSection.Default, "2.0"); Assert.Equal(1, msbuildToolsetSection.Toolsets.Count); Assert.Equal(msbuildToolsetSection.Toolsets.GetElement(0).toolsVersion, "2.0"); Assert.Equal(msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.Count, 1); Assert.Equal(msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.GetElement("MSBuildBinPath").Value, @"D:\windows\Microsoft.NET\Framework\v2.0.x86ret\"); }
public void ExtensionsPathsTest_MultipleElementsWithSamePropertyNameForSameOS() { Assert.Throws <ConfigurationErrorsException>(() => { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets default=""4.0""> <toolset ToolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v3.5.x86ret\""/> <projectImportSearchPaths> <searchPaths os=""windows""> <property name=""MSBuildExtensionsPath"" value=""c:\foo""/> <property name=""MSBuildExtensionsPath"" value=""c:\bar""/> </searchPaths> </projectImportSearchPaths> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); config.GetSection(s_msbuildToolsets); } ); }
public void PropertyTest_GetValueByName() { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets default=""2.0""> <toolset toolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v2.0.x86ret\""/> <property name=""SomeOtherPropertyName"" value=""SomeOtherPropertyValue""/> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ToolsetConfigurationSection msbuildToolsetSection = config.GetSection(s_msbuildToolsets) as ToolsetConfigurationSection; // Verifications Assert.Equal(msbuildToolsetSection.Default, "2.0"); Assert.Equal(1, msbuildToolsetSection.Toolsets.Count); Assert.Equal(2, msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.Count); Assert.Equal(@"D:\windows\Microsoft.NET\Framework\v2.0.x86ret\", msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.GetElement("MSBuildBinPath").Value); Assert.Equal(@"SomeOtherPropertyValue", msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.GetElement("SomeOtherPropertyName").Value); }
public void ToolsVersionTest_MultipleElementsWithSameName() { Assert.Throws <ConfigurationErrorsException>(() => { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets default=""2.0""> <toolset toolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v2.0.x86ret\""/> </toolset> <toolset toolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v3.5.x86ret\""/> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ToolsetConfigurationSection msbuildToolsetSection = config.GetSection(s_msbuildToolsets) as ToolsetConfigurationSection; } ); }
public void ToolsVersionTest_SingleElement() { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets default=""4.0""> <toolset toolsVersion=""4.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v3.5.x86ret\""/> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ToolsetConfigurationSection msbuildToolsetSection = config.GetSection(s_msbuildToolsets) as ToolsetConfigurationSection; Assert.Equal("4.0", msbuildToolsetSection.Default); Assert.Single(msbuildToolsetSection.Toolsets); Assert.Equal("4.0", msbuildToolsetSection.Toolsets.GetElement(0).toolsVersion); Assert.Single(msbuildToolsetSection.Toolsets.GetElement("4.0").PropertyElements); Assert.Equal( @"D:\windows\Microsoft.NET\Framework\v3.5.x86ret\", msbuildToolsetSection.Toolsets.GetElement("4.0").PropertyElements.GetElement("MSBuildBinPath").Value); }
public void MSBuildToolsetsTest_Basic() { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""net.r_eg.IeXod.Evaluation.ToolsetConfigurationSection, net.r_eg.IeXod"" /> </configSections> <msbuildToolsets default=""2.0""> <toolset toolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v2.0.x86ret\""/> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ConfigurationSection section = config.GetSection(s_msbuildToolsets); ToolsetConfigurationSection msbuildToolsetSection = section as ToolsetConfigurationSection; Assert.Null(msbuildToolsetSection.MSBuildOverrideTasksPath); Assert.Equal("2.0", msbuildToolsetSection.Default); Assert.Single(msbuildToolsetSection.Toolsets); Assert.Equal("2.0", msbuildToolsetSection.Toolsets.GetElement(0).toolsVersion); Assert.Single(msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements); Assert.Equal( @"D:\windows\Microsoft.NET\Framework\v2.0.x86ret\", msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.GetElement("MSBuildBinPath").Value); Assert.Empty(msbuildToolsetSection.Toolsets.GetElement(0).AllProjectImportSearchPaths); }
public void PropertyTest_ValueNotSpecified() { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets default=""4.0""> <toolset name=""4.0""> <property name=""MSBuildBinPath"" /> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ToolsetConfigurationSection msbuildToolsetSection = config.GetSection(s_msbuildToolsets) as ToolsetConfigurationSection; }
public void PropertyTest_NameNotSpecified() { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets default=""4.0""> <toolset toolsVersion=""4.0""> <property value=""D:\windows\Microsoft.NET\Framework\v3.5.x86ret\""/> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ToolsetConfigurationSection msbuildToolsetSection = config.GetSection(s_msbuildToolsets) as ToolsetConfigurationSection; }
public void MSBuildToolsetsTest_EmptyElement() { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets /> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ToolsetConfigurationSection msbuildToolsetSection = config.GetSection(s_msbuildToolsets) as ToolsetConfigurationSection; Assert.Equal(msbuildToolsetSection.MSBuildOverrideTasksPath, null); Assert.NotNull(msbuildToolsetSection); Assert.Equal(null, msbuildToolsetSection.Default); Assert.NotNull(msbuildToolsetSection.Toolsets); Assert.Equal(0, msbuildToolsetSection.Toolsets.Count); }
public void MSBuildToolsetsTest_BasicWithOtherConfigEntries() { // NOTE: for some reason, <configSections> MUST be the first element under <configuration> // for the API to read it. The docs don't make this clear. ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <startup> <supportedRuntime imageVersion=""v2.0.60510"" version=""v2.0.x86chk""/> <requiredRuntime imageVersion=""v2.0.60510"" version=""v2.0.x86chk"" safemode=""true""/> </startup> <msbuildToolsets default=""2.0""> <toolset toolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v2.0.x86ret\""/> </toolset> </msbuildToolsets> <runtime> <assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1""> <dependentAssembly> <assemblyIdentity name=""Microsoft.Build.Framework"" publicKeyToken=""b03f5f7f11d50a3a"" culture=""neutral""/> <bindingRedirect oldVersion=""0.0.0.0-99.9.9.9"" newVersion=""2.0.0.0""/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ToolsetConfigurationSection msbuildToolsetSection = config.GetSection(s_msbuildToolsets) as ToolsetConfigurationSection; Assert.Equal("2.0", msbuildToolsetSection.Default); Assert.Single(msbuildToolsetSection.Toolsets); Assert.Equal("2.0", msbuildToolsetSection.Toolsets.GetElement(0).toolsVersion); Assert.Single(msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements); Assert.Equal( @"D:\windows\Microsoft.NET\Framework\v2.0.x86ret\", msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.GetElement("MSBuildBinPath").Value); Assert.Empty(msbuildToolsetSection.Toolsets.GetElement(0).AllProjectImportSearchPaths); }
public void MSBuildToolsetsTest_Basic2() { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""net.r_eg.IeXod.Evaluation.ToolsetConfigurationSection, net.r_eg.IeXod"" /> </configSections> <msbuildToolsets default=""2.0"" msbuildOverrideTasksPath=""c:\foo""> <toolset toolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v2.0.x86ret\""/> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ConfigurationSection section = config.GetSection(s_msbuildToolsets); ToolsetConfigurationSection msbuildToolsetSection = section as ToolsetConfigurationSection; Assert.Equal("c:\\foo", msbuildToolsetSection.MSBuildOverrideTasksPath); }
public void PropertyTest_ValueNotSpecified() { Assert.Throws <ConfigurationErrorsException>(() => { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""net.r_eg.IeXod.Evaluation.ToolsetConfigurationSection, net.r_eg.IeXod"" /> </configSections> <msbuildToolsets default=""4.0""> <toolset name=""4.0""> <property name=""MSBuildBinPath"" /> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); config.GetSection(s_msbuildToolsets); } ); }
public void PropertyTest_NameNotSpecified() { Assert.Throws <ConfigurationErrorsException>(() => { ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""net.r_eg.IeXod.Evaluation.ToolsetConfigurationSection, net.r_eg.IeXod"" /> </configSections> <msbuildToolsets default=""4.0""> <toolset toolsVersion=""4.0""> <property value=""D:\windows\Microsoft.NET\Framework\v3.5.x86ret\""/> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); config.GetSection(s_msbuildToolsets); } ); }
public void ExtensionPathsTest_Basic1() { // NOTE: for some reason, <configSections> MUST be the first element under <configuration> // for the API to read it. The docs don't make this clear. ToolsetConfigurationReaderTestHelper.WriteConfigFile(ObjectModelHelpers.CleanupFileContents(@" <configuration> <configSections> <section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build"" /> </configSections> <msbuildToolsets default=""2.0""> <toolset toolsVersion=""2.0""> <property name=""MSBuildBinPath"" value=""D:\windows\Microsoft.NET\Framework\v2.0.x86ret\""/> <property name=""MSBuildToolsPath"" value=""D:\windows\Microsoft.NET\Framework\v2.0.x86ret\""/> <projectImportSearchPaths> <searchPaths os=""windows""> <property name=""MSBuildExtensionsPath"" value=""c:\foo""/> <property name=""MSBuildExtensionsPath64"" value=""c:\foo64;c:\bar64""/> </searchPaths> <searchPaths os=""osx""> <property name=""MSBuildExtensionsPath"" value=""/tmp/foo""/> <property name=""MSBuildExtensionsPath32"" value=""/tmp/foo32;/tmp/bar32""/> </searchPaths> <searchPaths os=""unix""> <property name=""MSBuildExtensionsPath"" value=""/tmp/bar""/> </searchPaths> </projectImportSearchPaths> </toolset> </msbuildToolsets> </configuration>")); Configuration config = ToolsetConfigurationReaderTestHelper.ReadApplicationConfigurationTest(); ToolsetConfigurationSection msbuildToolsetSection = config.GetSection(s_msbuildToolsets) as ToolsetConfigurationSection; Assert.Equal(msbuildToolsetSection.Default, "2.0"); Assert.Equal(1, msbuildToolsetSection.Toolsets.Count); Assert.Equal(msbuildToolsetSection.Toolsets.GetElement(0).toolsVersion, "2.0"); Assert.Equal(msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.Count, 2); Assert.Equal(msbuildToolsetSection.Toolsets.GetElement("2.0").PropertyElements.GetElement("MSBuildBinPath").Value, @"D:\windows\Microsoft.NET\Framework\v2.0.x86ret\"); Assert.Equal(msbuildToolsetSection.Toolsets.GetElement(0).AllProjectImportSearchPaths.Count, 3); var allPaths = msbuildToolsetSection.Toolsets.GetElement(0).AllProjectImportSearchPaths; Assert.Equal(allPaths.GetElement(0).OS, "windows"); Assert.Equal(allPaths.GetElement(0).PropertyElements.Count, 2); Assert.Equal(allPaths.GetElement(0).PropertyElements.GetElement("MSBuildExtensionsPath").Value, @"c:\foo"); Assert.Equal(allPaths.GetElement(0).PropertyElements.GetElement("MSBuildExtensionsPath64").Value, @"c:\foo64;c:\bar64"); Assert.Equal(allPaths.GetElement(1).OS, "osx"); Assert.Equal(allPaths.GetElement(1).PropertyElements.Count, 2); Assert.Equal(allPaths.GetElement(1).PropertyElements.GetElement("MSBuildExtensionsPath").Value, @"/tmp/foo"); Assert.Equal(allPaths.GetElement(1).PropertyElements.GetElement("MSBuildExtensionsPath32").Value, @"/tmp/foo32;/tmp/bar32"); Assert.Equal(allPaths.GetElement(2).OS, "unix"); Assert.Equal(allPaths.GetElement(2).PropertyElements.Count, 1); Assert.Equal(allPaths.GetElement(2).PropertyElements.GetElement("MSBuildExtensionsPath").Value, @"/tmp/bar"); var reader = GetStandardConfigurationReader(); Dictionary <string, Toolset> toolsets = new Dictionary <string, Toolset>(StringComparer.OrdinalIgnoreCase); string msbuildOverrideTasksPath = null; string defaultOverrideToolsVersion = null; reader.ReadToolsets(toolsets, new PropertyDictionary <ProjectPropertyInstance>(), new PropertyDictionary <ProjectPropertyInstance>(), true, out msbuildOverrideTasksPath, out defaultOverrideToolsVersion); Dictionary <string, ProjectImportPathMatch> pathsTable = toolsets["2.0"].ImportPropertySearchPathsTable; if (NativeMethodsShared.IsWindows) { CheckPathsTable(pathsTable, "MSBuildExtensionsPath", new string[] { "c:\\foo" }); CheckPathsTable(pathsTable, "MSBuildExtensionsPath64", new string[] { "c:\\foo64", "c:\\bar64" }); } else if (NativeMethodsShared.IsOSX) { CheckPathsTable(pathsTable, "MSBuildExtensionsPath", new string[] { "/tmp/foo" }); CheckPathsTable(pathsTable, "MSBuildExtensionsPath32", new string[] { "/tmp/foo32", "/tmp/bar32" }); } else { CheckPathsTable(pathsTable, "MSBuildExtensionsPath", new string[] { "/tmp/bar" }); } }