Beispiel #1
0
        static void Main(string[] args)
        {
            //find out how to initialize Engine property of the Task in .NET 4 version of MSBuild
            Engine engine = new Engine();
            engine.BinPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.System)
                + @"\..\Microsoft.NET\Framework\v2.0.50727";

            FileLogger logger = new FileLogger();
            logger.Parameters = @"logfile=C:\temp\test.msbuild.log";
            engine.RegisterLogger(logger);

            string[] tasks = new string[] { "MyTask" };
            BuildPropertyGroup props = new BuildPropertyGroup();
            props.SetProperty("parm1","hello Build!");

            var task = new RazorCodeGen();
            const string path = @"C:\work\projects\SyncCloud.Backend\AirPlans.Web\";
            task.ProjectRoot = path;
            task.CodeGenDirectory = Path.Combine(task.ProjectRoot, @"obj\CodeGen\Views\");
            var allViewFiles = Directory.EnumerateFiles(Path.Combine(task.ProjectRoot, @"Views\"), "*.cshtml", SearchOption.AllDirectories).ToList();
            task.FilesToPrecompile = allViewFiles.Select(x => new TaskItem(x)).ToArray();

            task.Execute();

            Console.ReadKey();
        }
        public void TestIndexer1()
        {
            BuildPropertyGroup bpg = new BuildPropertyGroup();

            bpg.SetProperty("a", "1");
            bpg.SetProperty("b", "2");

            Assert.AreEqual("a", bpg ["a"].Name, "A1");
            Assert.AreEqual("b", bpg ["b"].Name, "A2");
            Assert.IsNull(bpg ["something_that_doesnt_exist"], "A3");
            bpg ["a"].Value = "3";
            Assert.AreEqual("3", bpg ["a"].Value, "A4");
        }
Beispiel #3
0
        public void NoItemsConsumed()
        {
            List <string> parameters = new List <string>();

            parameters.Add("$(File)");
            parameters.Add("%(Culture)");

            Hashtable          itemsByType = new Hashtable(StringComparer.OrdinalIgnoreCase);
            BuildPropertyGroup properties  = new BuildPropertyGroup();

            // This is expected to throw because we have no idea what item list %(Culture) refers to.
            ArrayList buckets = BatchingEngine.PrepareBatchingBuckets(new XmlDocument().CreateElement("Foo"), parameters, CreateLookup(itemsByType, properties));
        }
Beispiel #4
0
        public void Project_ReleaseConfiguation_ReturnsCorrectDebugType()
        {
            Project project = new Project(Engine.GlobalEngine);

            project.Load(@"Data\Project1.proj");
            project.GlobalProperties.SetProperty("Configuration", "Release");

            BuildPropertyGroup properties = project.EvaluatedProperties;
            var debugTypeProperty         = properties["DebugType"];

            Assert.IsNotNull(debugTypeProperty);
            Assert.AreEqual("pdbonly", debugTypeProperty.FinalValue);
        }
Beispiel #5
0
        private static ItemDefinitionLibrary NewAndEvaluateItemDefinitionLibraryXml(XmlElement group)
        {
            ItemDefinitionLibrary library = new ItemDefinitionLibrary(new Project());

            library.Add(group);

            BuildPropertyGroup properties = new BuildPropertyGroup();

            properties.SetProperty("p1", "v1");
            library.Evaluate(properties);

            return(library);
        }
Beispiel #6
0
        public void TestConstructor()
        {
            BuildPropertyGroup default_scope = new BuildPropertyGroup(new Project());

            Assertion.AssertNotNull(default_scope);

            CacheScope testScope = new CacheScope("Test.proj", default_scope, "2.0");

            Assert.AreEqual(testScope.ScopeProperties, default_scope, "Expected ScopeProperties to be set");

            // We should have detached the parent project from the property group, to avoid holding on to it in the cache
            Assertion.AssertEquals(null, testScope.ScopeProperties.ParentProject);
        }
 private void AddTypeGuidToGroup(BuildPropertyGroup group)
 {
     if (DoesImportTarget(csharpImportPath))
     {
         group.AddNewProperty(TypeGuidsProperty,
                              string.Format("{0};{1}", WpfProjectTypeGuid, csharpProjectTypeGuid));
     }
     else if (DoesImportTarget(vbImportPath))
     {
         group.AddNewProperty(TypeGuidsProperty,
                              string.Format("{0};{1}", WpfProjectTypeGuid, vbProjectTypeGuid));
     }
 }
Beispiel #8
0
 internal override void CreateFromStream(BinaryReader reader)
 {
     base.CreateFromStream(reader);
     #region Entries
     if (reader.ReadByte() == 0)
     {
         entries = null;
     }
     else
     {
         int numberOfEntries = reader.ReadInt32();
         entries = new CacheEntry[numberOfEntries];
         for (int i = 0; i < entries.Length; i++)
         {
             entries[i] = CacheEntryCustomSerializer.CreateFromStream(reader);
         }
     }
     #endregion
     #region ScopeName
     if (reader.ReadByte() == 0)
     {
         scopeName = null;
     }
     else
     {
         scopeName = reader.ReadString();
     }
     #endregion
     #region ScopeProperties
     if (reader.ReadByte() == 0)
     {
         scopeProperties = null;
     }
     else
     {
         scopeProperties = new BuildPropertyGroup();
         scopeProperties.CreateFromStream(reader);
     }
     #endregion
     #region ScopeToolsVersion
     if (reader.ReadByte() == 0)
     {
         scopeToolsVersion = null;
     }
     else
     {
         scopeToolsVersion = reader.ReadString();
     }
     #endregion
     cacheContentType = (CacheContentType)reader.ReadByte();
 }
Beispiel #9
0
        public void TestGlobalProperties4c()
        {
            string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
                                 + GetUsingTask("MSBuild")
                                 + @"
	<Target Name=""main"">
		<MSBuild Projects=""first.proj"" Targets = ""1""/>
		<CallTarget Targets=""Call2""/>
		<Message Text=""second""/>
		<MSBuild Projects=""first.proj"" Targets = ""1;2""/>
	</Target>
	<Target Name=""Call2"">
		<MSBuild Projects=""first.proj"" Targets = ""2""/>
	</Target>
</Project>";

            string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
                                  + GetUsingTask("MSBuild")
                                  + @"
	<Target Name = ""1"">
		<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
		<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
	</Target>
	<Target Name=""2"">
		<MSBuild Projects=""second.proj"" Targets = ""TargetA""/>
		<MSBuild Projects=""second.proj"" Targets = ""TargetA""/>
		<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo"" />
		<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo1"" />
	</Target>
</Project>
";

            BuildPropertyGroup globalprops = new BuildPropertyGroup();

            globalprops.SetProperty("foo", "EngineFooValue");

            BuildPropertyGroup project_globalprops = new BuildPropertyGroup();

            project_globalprops.SetProperty("foo", "ProjFooValue");

            CreateAndCheckGlobalPropertiesTest(mainProject, firstProject, secondProject,
                                               globalprops, project_globalprops,
                                               10, 8, 15,
                                               new string [] {
                "(TargetA) foo: bar A:  External: ",
                "(TargetB) foo: foofoo A:  External: ",
                "(TargetA) foo: ProjFooValue A:  External: ",
                "(TargetB) foo: foofoo1 A:  External: ",
                "second"
            });
        }
Beispiel #10
0
        public void TestGlobalProperties4b()
        {
            string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
	<UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
	<Target Name=""main"">
		<MSBuild Projects=""first.proj"" Targets = ""1""/>
		<CallTarget Targets=""Call2""/>
		<Message Text=""second""/>
		<MSBuild Projects=""first.proj"" Targets = ""1;2""/>
	</Target>
	<Target Name=""Call2"">
		<MSBuild Projects=""first.proj"" Targets = ""2""/>
	</Target>
</Project>";

            string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
	<UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
		AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
	<Target Name = ""1"">
		<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
		<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
	</Target>
	<Target Name=""2"">
		<MSBuild Projects=""second.proj"" Targets = ""TargetA""/>
		<MSBuild Projects=""second.proj"" Targets = ""TargetA""/>
		<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo"" />
		<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo1"" />
	</Target>
</Project>
";

            BuildPropertyGroup globalprops = new BuildPropertyGroup();

            globalprops.SetProperty("external", "ExternalValue");

            BuildPropertyGroup project_globalprops = new BuildPropertyGroup();

            project_globalprops.SetProperty("external", "ProjExternalValue");
            project_globalprops.SetProperty("foo", "ProjFooValue");

            CreateAndCheckGlobalPropertiesTest(mainProject, firstProject, secondProject,
                                               globalprops, project_globalprops,
                                               10, 8, 15,
                                               new string [] {
                "(TargetA) foo: bar A:  External: ProjExternalValue",
                "(TargetB) foo: foofoo A:  External: ProjExternalValue",
                "(TargetA) foo: ProjFooValue A:  External: ProjExternalValue",
                "(TargetB) foo: foofoo1 A:  External: ProjExternalValue",
                "second"
            });
        }
Beispiel #11
0
        /// <summary>
        /// Constructor that also associates a set of properties with the tools version
        /// </summary>
        /// <param name="toolsVersion">Name of the toolset</param>
        /// <param name="toolsPath">Path to this toolset's tasks and targets</param>
        /// <param name="buildProperties">Properties that should be associated with the Toolset.
        /// May be null, in which case an empty property group will be used.</param>
        public Toolset(string toolsVersion, string toolsPath, BuildPropertyGroup buildProperties)
        {
            ErrorUtilities.VerifyThrowArgumentLength(toolsVersion, "toolsVersion");
            ErrorUtilities.VerifyThrowArgumentLength(toolsPath, "toolsPath");

            this.toolsVersion = toolsVersion;
            this.ToolsPath    = toolsPath;

            this.properties = new BuildPropertyGroup();
            if (buildProperties != null)
            {
                this.properties.ImportProperties(buildProperties);
            }
        }
Beispiel #12
0
        public void TestRemoveProperty3()
        {
            BuildPropertyGroup bpg = new BuildPropertyGroup();

            bpg.SetProperty("a", "b");
            bpg.SetProperty("c", "d");

            bpg.RemoveProperty("value_not_in_group");
            bpg.RemoveProperty(new BuildProperty("name", "value"));

            BuildProperty bp = bpg ["a"];

            bpg.RemoveProperty(bp);
        }
Beispiel #13
0
        public void ResetBuildStatusForAllProjects()
        {
            // Initialize engine.  Need two separate engines because we don't allow two
            // projects with the same full path to be loaded in the same Engine.
            Engine engine1 = new Engine(@"c:\");
            Engine engine2 = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up a global property group.
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();

            globalProperties.SetProperty("Configuration", "Release");

            // Create a few new projects.
            Project project1 = new Project(engine1);

            project1.FullFileName     = @"c:\rajeev\temp\myapp.proj";
            project1.GlobalProperties = globalProperties;

            Project project2 = new Project(engine1);

            project2.FullFileName     = @"c:\blah\foo.proj";
            project2.GlobalProperties = globalProperties;

            Project project3 = new Project(engine2);

            project3.FullFileName = @"c:\blah\foo.proj";
            globalProperties.SetProperty("Configuration", "Debug");
            project3.GlobalProperties = globalProperties;

            // Add the new projects to the ProjectManager.
            projectManager.AddProject(project1);
            projectManager.AddProject(project2);
            projectManager.AddProject(project3);

            // Put all the projects in a non-reset state.
            project1.IsReset = false;
            project2.IsReset = false;
            project3.IsReset = false;

            // Call ResetAllProjects.
            projectManager.ResetBuildStatusForAllProjects();

            // Make sure they all got reset.
            Assertion.Assert(project1.IsReset);
            Assertion.Assert(project2.IsReset);
            Assertion.Assert(project3.IsReset);
        }
Beispiel #14
0
        public void CloneDeepClear()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();

            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");

            BuildPropertyGroup clone = group.Clone(true);

            clone.Clear();

            Assertion.AssertEquals(0, clone.Count);
            Assertion.AssertEquals(2, group.Count);
        }
Beispiel #15
0
        public void CountAfterRemovingAllProperties()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();

            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");
            group.SetProperty("n3", "v3");

            group.RemoveProperty("n1");
            group.RemoveProperty("n2");
            group.RemoveProperty("n3");

            Assertion.AssertEquals(0, group.Count);
        }
Beispiel #16
0
        public void UnmodifiedProperty()
        {
            BuildPropertyGroup group    = new BuildPropertyGroup();
            BuildProperty      property = new BuildProperty("p1", "v1");

            group.SetProperty(property);
            Lookup lookup = LookupHelpers.CreateLookup(group);

            Assertion.AssertEquals(property, lookup.GetProperty("p1"));

            lookup.EnterScope();

            Assertion.AssertEquals(property, lookup.GetProperty("p1"));
        }
Beispiel #17
0
        /// <summary>
        /// Called either on the main or child node. This is the routing method for setting cache entries.
        /// </summary>
        public void SetCacheEntries
        (
            int handleId, CacheEntry[] entries,
            string cacheScope, string cacheKey, string cacheVersion,
            CacheContentType cacheContentType, bool localNodeOnly
        )
        {
            TaskExecutionContext executionContext = GetTaskContextFromHandleId(handleId);
            BuildPropertyGroup   scopeProperties;

            if (cacheKey == null)
            {
                Project parentProject = executionContext.ParentProject;
                scopeProperties = parentProject.GlobalProperties;
            }
            else
            {
                // Property values are compared using case sensitive comparisons because the case of property values do have meaning.
                // In this case we are using properties in a manner where we do not want case sensitive comparisons.
                // There is not enough benefit for this one special case to add case insensitive
                // comparisons to build properties. We instead uppercase all of the keys for both get and set CachedEntries.
                scopeProperties = new BuildPropertyGroup();
                scopeProperties.SetProperty("CacheKey", cacheKey.ToUpper(CultureInfo.InvariantCulture));
            }

            if (cacheScope == null)
            {
                cacheScope = executionContext.ParentProject.FullFileName;
            }

            if (cacheVersion == null)
            {
                cacheVersion = executionContext.ParentProject.ToolsVersion;
            }

            parentEngine.CacheManager.SetCacheEntries(entries, cacheScope, scopeProperties, cacheVersion, cacheContentType);

            // Also send these to the parent if we're allowed to
            if (parentEngine.Router.ChildMode && !localNodeOnly)
            {
                Exception exception = parentEngine.Router.ParentNode.PostCacheEntriesToHost(entries, cacheScope, scopeProperties, cacheVersion, cacheContentType);

                // If we had problems on the parent node, rethrow the exception here
                if (exception != null)
                {
                    throw exception;
                }
            }
        }
Beispiel #18
0
        public void RemovePropertyByNameOneOfSeveral()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();

            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");
            group.SetProperty("n3", "v3");

            group.RemoveProperty("n1");

            Assertion.AssertEquals(2, group.Count);
            Assertion.AssertNull(group["n1"]);
            Assertion.AssertEquals("v2", group["n2"].Value);
            Assertion.AssertEquals("v3", group["n3"].Value);
        }
Beispiel #19
0
        public Parameters()
        {
            consoleLoggerParameters = "";
            displayHelp             = false;
            loggers         = new ArrayList();
            loggerVerbosity = LoggerVerbosity.Normal;
            noConsoleLogger = false;
            noLogo          = false;
            properties      = new BuildPropertyGroup();
            targets         = new string [0];

            responseFile = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "xbuild.rsp");
        }
Beispiel #20
0
        public void PropertyGroupIsEquivalent_DifferentCount()
        {
            BuildPropertyGroup pg1 = new BuildPropertyGroup();
            BuildPropertyGroup pg2 = new BuildPropertyGroup();

            pg1.SetProperty("Elmo", "Red");
            pg1.SetProperty("BigBird", "Yellow");
            pg1.SetProperty("OscartheGrouch", "Green");

            pg2.SetProperty("Elmo", "Red");
            pg2.SetProperty("BigBird", "Yellow");

            // The two property bags are not equivalent.
            Assertion.Assert(!pg1.IsEquivalent(pg2));
        }
Beispiel #21
0
 /// <summary>
 /// Sets the given property in the given property group.
 /// </summary>
 /// <param name="property"></param>
 /// <param name="propertyGroup"></param>
 /// <param name="globalProperties"></param>
 private void SetProperty(PropertyDefinition property, BuildPropertyGroup propertyGroup, BuildPropertyGroup globalProperties)
 {
     try
     {
         // Global properties cannot be overwritten
         if (globalProperties[property.Name] == null)
         {
             propertyGroup.SetProperty(property.Name, property.Value);
         }
     }
     catch (ArgumentException ex)
     {
         InvalidToolsetDefinitionException.Throw(ex, "InvalidPropertyNameInToolset", property.Name, property.Source, ex.Message);
     }
 }
Beispiel #22
0
        /// <summary>
        /// Adds a new property group for a new configuration or platform.
        /// </summary>
        /// <param name="config">Configuration name of the full configuration being added.</param>
        /// <param name="platform">Platform name of the full configuration being added.</param>
        /// <param name="cloneCondition">Condition of property group to clone, if it exists.</param>
        private void AddNewConfigPropertyGroup(string config, string platform, string cloneCondition)
        {
            BuildPropertyGroup newPropertyGroup = null;

            if (!String.IsNullOrEmpty(cloneCondition))
            {
                foreach (BuildPropertyGroup propertyGroup in this.ProjectMgr.BuildProject.PropertyGroups)
                {
                    if (String.Equals(propertyGroup.Condition.Trim(), cloneCondition.Trim(), StringComparison.OrdinalIgnoreCase))
                    {
                        newPropertyGroup = this.ProjectMgr.ClonePropertyGroup(propertyGroup);
                        newPropertyGroup.RemoveProperty(WixProjectFileConstants.OutputPath);
                        newPropertyGroup.RemoveProperty(WixProjectFileConstants.IntermediateOutputPath);
                        break;
                    }
                }
            }

            if (newPropertyGroup == null)
            {
                newPropertyGroup = this.ProjectMgr.BuildProject.AddNewPropertyGroup(false);
                IList <KeyValuePair <KeyValuePair <string, string>, string> > propVals = this.NewConfigProperties;
                foreach (KeyValuePair <KeyValuePair <string, string>, string> data in propVals)
                {
                    KeyValuePair <string, string> propData = data.Key;
                    string        value       = data.Value;
                    BuildProperty newProperty = newPropertyGroup.AddNewProperty(propData.Key, value);
                    if (!String.IsNullOrEmpty(propData.Value))
                    {
                        newProperty.Condition = propData.Value;
                    }
                }
            }

            string outputBasePath = this.ProjectMgr.OutputBaseRelativePath;
            string outputPath     = Path.Combine(outputBasePath, WixConfigProvider.ConfigPath);

            newPropertyGroup.AddNewProperty(WixProjectFileConstants.OutputPath, outputPath);

            string intermediateBasePath = WixConfigProvider.IntermediateBaseRelativePath;
            string intermediatePath     = Path.Combine(intermediateBasePath, WixConfigProvider.ConfigPath);

            newPropertyGroup.AddNewProperty(WixProjectFileConstants.IntermediateOutputPath, intermediatePath);

            string newCondition = String.Format(CultureInfo.InvariantCulture, WixProjectConfig.ConfigAndPlatformConditionString, config, platform);

            newPropertyGroup.Condition = newCondition;
        }
Beispiel #23
0
        void AddCurrentSolutionConfigurationContents(Project p, List <TargetInfo> solutionTargets,
                                                     Dictionary <Guid, ProjectInfo> projectInfos,
                                                     Dictionary <Guid, ProjectInfo> websiteProjectInfos)
        {
            TargetInfo default_target_info = new TargetInfo("Debug", "Any CPU");

            if (solutionTargets.Count > 0)
            {
                bool found = false;
                foreach (TargetInfo tinfo in solutionTargets)
                {
                    if (String.Compare(tinfo.Platform, "Mixed Platforms") == 0)
                    {
                        default_target_info = tinfo;
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    default_target_info = solutionTargets [0];
                }
            }

            AddDefaultSolutionConfiguration(p, default_target_info);

            foreach (TargetInfo solutionTarget in solutionTargets)
            {
                BuildPropertyGroup platformPropertyGroup = p.AddNewPropertyGroup(false);
                platformPropertyGroup.Condition = string.Format(
                    " ('$(Configuration)' == '{0}') and ('$(Platform)' == '{1}') ",
                    solutionTarget.Configuration,
                    solutionTarget.Platform
                    );

                StringBuilder solutionConfigurationContents = new StringBuilder();
                solutionConfigurationContents.Append("<SolutionConfiguration xmlns=\"\">");
                foreach (KeyValuePair <Guid, ProjectInfo> projectInfo in projectInfos)
                {
                    AddProjectConfigurationItems(projectInfo.Key, projectInfo.Value, solutionTarget, solutionConfigurationContents);
                }
                solutionConfigurationContents.Append("</SolutionConfiguration>");

                platformPropertyGroup.AddNewProperty("CurrentSolutionConfigurationContents",
                                                     solutionConfigurationContents.ToString());
            }
        }
Beispiel #24
0
        public void SetPropertyValueWithSpecialCharacters()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();

            group.SetProperty("n1", "%24");
            group.SetProperty("n2", "%40");
            group.SetProperty("n3", "%3b");
            group.SetProperty("n4", "%5c");
            group.SetProperty("n5", "%25");

            Assertion.AssertEquals("$", group["n1"].FinalValue);
            Assertion.AssertEquals("@", group["n2"].FinalValue);
            Assertion.AssertEquals(";", group["n3"].FinalValue);
            Assertion.AssertEquals(@"\", group["n4"].FinalValue);
            Assertion.AssertEquals("%", group["n5"].FinalValue);
        }
Beispiel #25
0
        void AddGeneralSettings(string solutionFile, Project p)
        {
            p.DefaultTargets = "Build";
            p.InitialTargets = "ValidateSolutionConfiguration";
            p.AddNewUsingTaskFromAssemblyName("CreateTemporaryVCProject", "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
            p.AddNewUsingTaskFromAssemblyName("ResolveVCProjectOutput", "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");

            string             solutionFilePath      = Path.GetFullPath(solutionFile);
            BuildPropertyGroup solutionPropertyGroup = p.AddNewPropertyGroup(true);

            solutionPropertyGroup.AddNewProperty("SolutionDir", Path.GetDirectoryName(solutionFilePath) + Path.DirectorySeparatorChar);
            solutionPropertyGroup.AddNewProperty("SolutionExt", Path.GetExtension(solutionFile));
            solutionPropertyGroup.AddNewProperty("SolutionFileName", Path.GetFileName(solutionFile));
            solutionPropertyGroup.AddNewProperty("SolutionName", Path.GetFileNameWithoutExtension(solutionFile));
            solutionPropertyGroup.AddNewProperty("SolutionPath", solutionFilePath);
        }
Beispiel #26
0
            /// <summary>
            /// Given the properties and dictionary of previously encountered item definitions, evaluates
            /// this group of item definitions and adds to the dictionary as necessary.
            /// </summary>
            /// <exception cref="InvalidProjectFileException">If the item definitions are incorrectly defined</exception>
            internal void Evaluate(BuildPropertyGroup properties, ItemDefinitionsDictionary itemDefinitionsDictionary)
            {
                Expander expander = new Expander(properties);

                if (!Utilities.EvaluateCondition(condition, conditionAttribute, expander, ParserOptions.AllowProperties, parentProject))
                {
                    return;
                }

                List <XmlElement> childElements = ProjectXmlUtilities.GetValidChildElements(element);

                foreach (XmlElement child in childElements)
                {
                    EvaluateItemDefinitionElement(child, properties, itemDefinitionsDictionary);
                }
            }
Beispiel #27
0
        public void RemoveProjectsByFullPath()
        {
            // Initialize engine.  Need two separate engines because we don't allow two
            // projects with the same full path to be loaded in the same Engine.
            Engine engine1 = new Engine(@"c:\");
            Engine engine2 = new Engine(@"c:\");

            // Instantiate new project manager.
            ProjectManager projectManager = new ProjectManager();

            // Set up a global property group.
            BuildPropertyGroup globalProperties = new BuildPropertyGroup();

            globalProperties.SetProperty("Configuration", "Release");

            // Create a few new projects.
            Project project1 = new Project(engine1);

            project1.FullFileName     = @"c:\rajeev\temp\myapp.proj";
            project1.GlobalProperties = globalProperties;

            Project project2 = new Project(engine1);

            project2.FullFileName     = @"c:\blah\foo.proj";
            project2.GlobalProperties = globalProperties;

            Project project3 = new Project(engine2);

            project3.FullFileName = @"c:\blah\foo.proj";
            globalProperties.SetProperty("Configuration", "Debug");
            project3.GlobalProperties = globalProperties;

            // Add the new projects to the ProjectManager.
            projectManager.AddProject(project1);
            projectManager.AddProject(project2);
            projectManager.AddProject(project3);

            // Remove all projects with the full path "c:\blah\foo.proj" (case insenstively).
            projectManager.RemoveProjects(@"c:\BLAH\FOO.Proj");

            // Make sure project 1 is still there.
            Assertion.AssertEquals(project1, projectManager.GetProject(project1.FullFileName, project1.GlobalProperties, null));

            // Make sure projects 2 and 3 are gone.
            Assertion.AssertNull(projectManager.GetProject(project2.FullFileName, project2.GlobalProperties, null));
            Assertion.AssertNull(projectManager.GetProject(project3.FullFileName, project3.GlobalProperties, null));
        }
Beispiel #28
0
        public void CloneShallowSetProperty()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();

            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");

            BuildPropertyGroup clone = group.Clone(false);

            group.SetProperty("n1", "new");

            Assertion.AssertEquals(2, clone.Count);
            Assertion.AssertEquals(2, group.Count);
            Assertion.AssertEquals("new", group["n1"].Value);
            Assertion.AssertEquals("v1", clone["n1"].Value);
            Assertion.AssertEquals(clone["n2"].Value, group["n2"].Value);
        }
Beispiel #29
0
        public void TestSetProperty4()
        {
            BuildPropertyGroup bpg = new BuildPropertyGroup();

            bpg.SetProperty("P1", "$(A)", true);
            bpg.SetProperty("P2", "$(A)", false);

            BuildProperty b1 = bpg ["P1"];
            BuildProperty b2 = bpg ["P2"];

            Assert.AreEqual("P1", b1.Name, "A1");
            Assert.AreEqual(Utilities.Escape("$(A)"), b1.Value, "A2");
            Assert.AreEqual("$(A)", b1.FinalValue, "A3");
            Assert.AreEqual("P2", b2.Name, "A4");
            Assert.AreEqual("$(A)", b2.Value, "A5");
            Assert.AreEqual("$(A)", b2.FinalValue, "A6");
        }
Beispiel #30
0
        public void RemovePropertyByBuildPropertyOneOfSeveral()
        {
            BuildPropertyGroup group = new BuildPropertyGroup();

            group.SetProperty("n1", "v1");
            group.SetProperty("n2", "v2");
            group.SetProperty("n3", "v3");

            BuildProperty property = GetSpecificBuildPropertyOutOfBuildPropertyGroup(group, "n2");

            group.RemoveProperty(property);

            Assertion.AssertEquals(2, group.Count);
            Assertion.AssertEquals("v1", group["n1"].Value);
            Assertion.AssertNull(group["n2"]);
            Assertion.AssertEquals("v3", group["n3"].Value);
        }
Beispiel #31
0
 internal override void CreateFromStream(BinaryReader reader)
 {
     base.CreateFromStream(reader);
     #region EnvironmentVariables
     int numberOfVariables = reader.ReadInt32();
     environmentVariables = new Hashtable(numberOfVariables);
     for (int i = 0; i < numberOfVariables; i++)
     {
         string key      = reader.ReadString();
         string variable = reader.ReadString();
         environmentVariables.Add(key, variable);
     }
     #endregion
     #region NodeLoggers
     if (reader.ReadByte() == 0)
     {
         nodeLoggers = null;
     }
     else
     {
         int numberOfLoggers = reader.ReadInt32();
         nodeLoggers = new LoggerDescription[numberOfLoggers];
         for (int i = 0; i < numberOfLoggers; i++)
         {
             LoggerDescription logger = new LoggerDescription();
             logger.CreateFromStream(reader);
             nodeLoggers[i] = logger;
         }
     }
     #endregion
     nodeId          = reader.ReadInt32();
     parentProcessId = reader.ReadInt32();
     #region ParentGlobalProperties
     if (reader.ReadByte() == 0)
     {
         parentGlobalProperties = null;
     }
     else
     {
         parentGlobalProperties = new BuildPropertyGroup();
         parentGlobalProperties.CreateFromStream(reader);
     }
     #endregion
     toolsetSearchLocations = (ToolsetDefinitionLocations)reader.ReadByte();
     parentStartupDirectory = (string)reader.ReadString();
 }
	public bool BuildProjectFile(string projectFile, string[] targetNames, BuildPropertyGroup globalProperties, System.Collections.IDictionary targetOutputs, BuildSettings buildFlags) {}
	public bool BuildProjectFile(string projectFile, string[] targetNames, BuildPropertyGroup globalProperties) {}
 public void RemovePropertyGroup(BuildPropertyGroup propertyGroupToRemove)
 {
 }