Exemplo n.º 1
0
        /// <summary>
        /// Add a target for a VC project file into the XML doc that's being generated.
        /// This is used only when building standalone VC projects
        /// </summary>
        /// <param name="msbuildProject"></param>
        /// <param name="projectPath"></param>
        /// <param name="targetName"></param>
        /// <param name="subTargetName"></param>
        /// <owner>RGoel</owner>
        static private void AddVCBuildTarget
        (
            Project msbuildProject,
            string projectPath,
            string targetName,
            string subTargetName
        )
        {
            Target newTarget = msbuildProject.Targets.AddNewTarget(targetName);

            if (subTargetName == "Publish")
            {
                // Well, hmmm.  The VCBuild doesn't support any kind of
                // a "Publish" operation.  The best we can really do is offer up a
                // message saying so.
                SolutionWrapperProject.AddErrorWarningMessageElement(newTarget, XMakeElements.error, true, "SolutionVCProjectNoPublish");
            }
            else
            {
                SolutionWrapperProject.AddErrorWarningMessageElement(newTarget, XMakeElements.warning, true, "StandaloneVCProjectP2PRefsBroken");

                string projectFullPath = Path.GetFullPath(projectPath);
                AddVCBuildTaskElement(msbuildProject, newTarget, "$(VCBuildSolutionFile)", projectFullPath, subTargetName, "$(PlatformName)", "$(ConfigurationName)");
            }
        }
Exemplo n.º 2
0
        public void AddNewErrorWarningMessageElement()
        {
            MockLogger logger  = new MockLogger();
            Project    project = ObjectModelHelpers.CreateInMemoryProject(
                "<Project DefaultTargets=`Build` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>" +
                "<Target Name=`Build`>" +
                "</Target>" +
                "</Project>",
                logger);

            Target target = project.Targets["Build"];

            SolutionWrapperProject.AddErrorWarningMessageElement(target, XMakeElements.message, true, "SolutionVenusProjectNoClean");
            SolutionWrapperProject.AddErrorWarningMessageElement(target, XMakeElements.warning, true, "SolutionParseUnknownProjectType", "proj1.csproj");
            SolutionWrapperProject.AddErrorWarningMessageElement(target, XMakeElements.error, true, "SolutionVCProjectNoPublish");

            project.Build(null, null);

            string code    = null;
            string keyword = null;
            string text    = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionParseUnknownProjectType", "proj1.csproj");

            // check the error event
            Assertion.AssertEquals(1, logger.Warnings.Count);
            BuildWarningEventArgs warning = logger.Warnings[0];

            Assertion.AssertEquals(text, warning.Message);
            Assertion.AssertEquals(code, warning.Code);
            Assertion.AssertEquals(keyword, warning.HelpKeyword);

            code    = null;
            keyword = null;
            text    = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionVCProjectNoPublish");

            // check the warning event
            Assertion.AssertEquals(1, logger.Errors.Count);
            BuildErrorEventArgs error = logger.Errors[0];

            Assertion.AssertEquals(text, error.Message);
            Assertion.AssertEquals(code, error.Code);
            Assertion.AssertEquals(keyword, error.HelpKeyword);

            code    = null;
            keyword = null;
            text    = ResourceUtilities.FormatResourceString(out code, out keyword, "SolutionVenusProjectNoClean");

            // check the message event
            Assertion.Assert("Log should contain the regular message", logger.FullLog.Contains(text));
        }