/// <summary>
        /// Creates a new project configuration store object.
        /// </summary>
        /// <param name="project">The project whose state this store will reflect.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if <c>project</c> is null.</exception>
        public ProjectConfigStore(IVsProject project)
        {
            _project = project;

            _buildTask = Factory.GetBuildManager().GetBuildTask(project, false);
            if (_buildTask != null)
            {
                ReadConfigFromBuildTask();
            }

            _termTableFiles.ItemAdded += new EventHandler<ItemEventArgs<string>>(_termTableFiles_ItemAdded);
            _termTableFiles.ItemsRemoved += new EventHandler(_termTableFiles_ItemsRemoved);
            _ignoreInstances.ItemAdded += new EventHandler<ItemEventArgs<BuildTask.IIgnoreInstance>>(_ignoreInstances_ItemAdded);
            _ignoreInstances.ItemsRemoved += new EventHandler(_ignoreInstances_ItemsRemoved);
        }
Esempio n. 2
0
		internal ProjectTaskInstance (ProjectTaskElement xml)
		{
			condition = xml.Condition;
			ContinueOnError = xml.ContinueOnError;
			Name = xml.Name;
			Outputs = xml.Outputs.Select (o => {
				if (o.IsOutputItem)
					return (ProjectTaskInstanceChild) new ProjectTaskOutputItemInstance ((ProjectOutputElement) o);
				if (o.IsOutputProperty)
					return new ProjectTaskOutputPropertyInstance ((ProjectOutputElement) o);
				throw new NotSupportedException ();
				}).ToArray ();
			Parameters = new Dictionary<string,string> (xml.Parameters);
			MSBuildArchitecture = xml.MSBuildArchitecture;
			MSBuildRuntime = xml.MSBuildRuntime;
			
			condition_location = xml.ConditionLocation;
			ContinueOnErrorLocation = xml.ContinueOnErrorLocation;
			location = xml.Location;
			MSBuildArchitectureLocation = xml.MSBuildArchitectureLocation;
			MSBuildRuntimeLocation = xml.MSBuildRuntimeLocation;
		}
Esempio n. 3
0
        public void GetBuildTaskWithNoCreation()
        {
            CodeSweep.VSPackage.BuildManager_Accessor accessor = new CodeSweep.VSPackage.BuildManager_Accessor(_serviceProvider);

            // Create a project without a build task.
            Microsoft.Build.Evaluation.Project project1 = Utilities.SetupMSBuildProject();
            MockIVsProject vsProject = Utilities.RegisterProjectWithMocks(project1, _serviceProvider);

            Assert.IsNull(accessor.GetBuildTask(vsProject, false), "GetBuildTask did not return null for project without a ScannerTask.");

            // Create a project with a build task.
            string scanFile  = Utilities.CreateTempTxtFile("foo abc foo def foo");
            string termTable = Utilities.CreateTermTable(new string[] { "foo", "bar" });

            Microsoft.Build.Evaluation.Project project2 = Utilities.SetupMSBuildProject(new string[] { scanFile }, new string[] { termTable });

            Microsoft.Build.Construction.ProjectTaskElement existingTask = Utilities.GetScannerTask(project2);

            vsProject = Utilities.RegisterProjectWithMocks(project2, _serviceProvider);

            Assert.AreEqual(existingTask, accessor.GetBuildTask(vsProject, false), "GetBuildTask did not return expected task object.");
            Assert.IsNull(GetImport(project2, Utilities.GetTargetsPath()), "GetBuildTask created Import unexpected.");
        }
Esempio n. 4
0
        /// <summary>
        /// Parse a ProjectOutputElement
        /// </summary>
        private ProjectOutputElement ParseProjectOutputElement(XmlElementWithLocation element, ProjectTaskElement parent)
        {
            ProjectXmlUtilities.VerifyThrowProjectAttributes(element, s_validAttributesOnOutput);
            ProjectXmlUtilities.VerifyThrowProjectRequiredAttribute(element, XMakeAttributes.taskParameter);
            ProjectXmlUtilities.VerifyThrowProjectNoChildElements(element);

            string taskParameter = element.GetAttribute(XMakeAttributes.taskParameter);
            string itemName      = element.GetAttribute(XMakeAttributes.itemName);
            string propertyName  = element.GetAttribute(XMakeAttributes.propertyName);

            ProjectErrorUtilities.VerifyThrowInvalidProject
            (
                (itemName.Length > 0 || propertyName.Length > 0) && (itemName.Length == 0 || propertyName.Length == 0),
                element.Location,
                "InvalidTaskOutputSpecification",
                parent.Name
            );

            ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, XMakeAttributes.itemName);
            ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, XMakeAttributes.propertyName);

            ProjectErrorUtilities.VerifyThrowInvalidProject(!ReservedPropertyNames.IsReservedProperty(propertyName), element.Location, "CannotModifyReservedProperty", propertyName);

            return(new ProjectOutputElement(element, parent, _project));
        }
Esempio n. 5
0
        /// <summary>
        /// Parse a ProjectOutputElement
        /// </summary>
        private ProjectOutputElement ParseProjectOutputElement(XmlElementWithLocation element, ProjectTaskElement parent)
        {
            ProjectXmlUtilities.VerifyThrowProjectAttributes(element, ValidAttributesOnOutput);
            ProjectXmlUtilities.VerifyThrowProjectRequiredAttribute(element, XMakeAttributes.taskParameter);
            ProjectXmlUtilities.VerifyThrowProjectNoChildElements(element);

            XmlAttributeWithLocation itemNameAttribute     = element.GetAttributeWithLocation(XMakeAttributes.itemName);
            XmlAttributeWithLocation propertyNameAttribute = element.GetAttributeWithLocation(XMakeAttributes.propertyName);

            ProjectErrorUtilities.VerifyThrowInvalidProject
            (
                (String.IsNullOrWhiteSpace(itemNameAttribute?.Value) && !String.IsNullOrWhiteSpace(propertyNameAttribute?.Value)) || (!String.IsNullOrWhiteSpace(itemNameAttribute?.Value) && String.IsNullOrWhiteSpace(propertyNameAttribute?.Value)),
                element.Location,
                "InvalidTaskOutputSpecification",
                parent.Name
            );

            ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, itemNameAttribute, XMakeAttributes.itemName);
            ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, propertyNameAttribute, XMakeAttributes.propertyName);

            ProjectErrorUtilities.VerifyThrowInvalidProject(String.IsNullOrWhiteSpace(propertyNameAttribute?.Value) || !ReservedPropertyNames.IsReservedProperty(propertyNameAttribute.Value), element.Location, "CannotModifyReservedProperty", propertyNameAttribute?.Value);

            return(new ProjectOutputElement(element, parent, _project));
        }
Esempio n. 6
0
        /// <summary>
        /// Parse a ProjectOutputElement
        /// </summary>
        private ProjectOutputElement ParseProjectOutputElement(XmlElementWithLocation element, ProjectTaskElement parent)
        {
            ProjectXmlUtilities.VerifyThrowProjectAttributes(element, s_validAttributesOnOutput);
            ProjectXmlUtilities.VerifyThrowProjectRequiredAttribute(element, XMakeAttributes.taskParameter);
            ProjectXmlUtilities.VerifyThrowProjectNoChildElements(element);

            string taskParameter = element.GetAttribute(XMakeAttributes.taskParameter);
            string itemName = element.GetAttribute(XMakeAttributes.itemName);
            string propertyName = element.GetAttribute(XMakeAttributes.propertyName);

            ProjectErrorUtilities.VerifyThrowInvalidProject
                (
                (itemName.Length > 0 || propertyName.Length > 0) && (itemName.Length == 0 || propertyName.Length == 0),
                element.Location,
                "InvalidTaskOutputSpecification",
                parent.Name
                );

            ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, XMakeAttributes.itemName);
            ProjectXmlUtilities.VerifyThrowProjectAttributeEitherMissingOrNotEmpty(element, XMakeAttributes.propertyName);

            ProjectErrorUtilities.VerifyThrowInvalidProject(!ReservedPropertyNames.IsReservedProperty(propertyName), element.Location, "CannotModifyReservedProperty", propertyName);

            return new ProjectOutputElement(element, parent, _project);
        }
Esempio n. 7
0
        /// <summary>
        /// Parse a ProjectTaskElement
        /// </summary>
        private ProjectTaskElement ParseProjectTaskElement(XmlElementWithLocation element, ProjectTargetElement parent)
        {
            foreach (XmlAttributeWithLocation attribute in element.Attributes)
            {
                ProjectErrorUtilities.VerifyThrowInvalidProject
                (
                !XMakeAttributes.IsBadlyCasedSpecialTaskAttribute(attribute.Name),
                attribute.Location,
                "BadlyCasedSpecialTaskAttribute",
                attribute.Name,
                element.Name,
                element.Name
                );
            }

            ProjectTaskElement task = new ProjectTaskElement(element, parent, _project);

            foreach (XmlElementWithLocation childElement in ProjectXmlUtilities.GetVerifyThrowProjectChildElements(element))
            {
                ProjectErrorUtilities.VerifyThrowInvalidProject(childElement.Name == XMakeElements.output, childElement.Location, "UnrecognizedChildElement", childElement.Name, task.Name);

                ProjectOutputElement output = ParseProjectOutputElement(childElement, task);

                task.AppendParentedChildNoChecks(output);
            }

            return task;
        }
 /// <summary>
 /// Initialize a parented ProjectOutputElement
 /// </summary>
 internal ProjectOutputElement(XmlElement xmlElement, ProjectTaskElement parent, ProjectRootElement containingProject)
     : base(xmlElement, parent, containingProject)
 {
     ErrorUtilities.VerifyThrowArgumentNull(parent, "parent");
 }
 void CreateBuildTaskIfNecessary()
 {
     if (_buildTask == null)
     {
         _buildTask = Factory.GetBuildManager().GetBuildTask(_project, true);
         ReadConfigFromBuildTask();
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Constructor called by Evaluator.
        /// All parameters are in the unevaluated state.
        /// Locations other than the main location may be null.
        /// </summary>
        internal ProjectTaskInstance
            (
            ProjectTaskElement element,
            IList<ProjectTaskInstanceChild> outputs
            )
        {
            ErrorUtilities.VerifyThrowInternalNull(element, "element");
            ErrorUtilities.VerifyThrowInternalNull(outputs, "outputs");

            // These are all immutable
            _name = element.Name;
            _condition = element.Condition;
            _continueOnError = element.ContinueOnError;
            _msbuildArchitecture = element.MSBuildArchitecture;
            _msbuildRuntime = element.MSBuildRuntime;
            _location = element.Location;
            _conditionLocation = element.ConditionLocation;
            _continueOnErrorLocation = element.ContinueOnErrorLocation;
            _msbuildRuntimeLocation = element.MSBuildRuntimeLocation;
            _msbuildArchitectureLocation = element.MSBuildArchitectureLocation;
            _parameters = element.ParametersForEvaluation;
            _outputs = new List<ProjectTaskInstanceChild>(outputs);
        }
Esempio n. 11
0
 /// <summary>
 /// Initialize a parented ProjectOutputElement
 /// </summary>
 internal ProjectOutputElement(XmlElement xmlElement, ProjectTaskElement parent, ProjectRootElement containingProject)
     : base(xmlElement, parent, containingProject)
 {
     ErrorUtilities.VerifyThrowArgumentNull(parent, "parent");
 }