当前位置: 首页>>代码示例>>C#>>正文


C# Project.AddNewPropertyGroup方法代码示例

本文整理汇总了C#中Microsoft.Build.BuildEngine.Project.AddNewPropertyGroup方法的典型用法代码示例。如果您正苦于以下问题:C# Project.AddNewPropertyGroup方法的具体用法?C# Project.AddNewPropertyGroup怎么用?C# Project.AddNewPropertyGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Build.BuildEngine.Project的用法示例。


在下文中一共展示了Project.AddNewPropertyGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override bool Execute()
        {
            bool result = true;

            string file = Path.Combine(m_stubsPath, m_name + ".featureproj");

            try
            {
                Project proj = new Project();
                proj.DefaultToolsVersion = "3.5";
                proj.DefaultTargets = "Build";

                BuildPropertyGroup bpg = proj.AddNewPropertyGroup(true);
                bpg.AddNewProperty("FeatureName", m_name);
                bpg.AddNewProperty("Guid", System.Guid.NewGuid().ToString("B"));
                bpg.AddNewProperty("Description", "");
                bpg.AddNewProperty("Groups", "");

                BuildItemGroup big = proj.AddNewItemGroup();
                big.AddNewItem("InteropFeature", Path.GetFileNameWithoutExtension(m_assemblyName).Replace('.', '_'));
                big.AddNewItem("DriverLibs", Path.GetFileNameWithoutExtension( m_assemblyName ).Replace( '.', '_' ) + ".$(LIB_EXT)");
                big.AddNewItem("MMP_DAT_CreateDatabase", "$(BUILD_TREE_CLIENT)\\pe\\" + m_assemblyName);
                big.AddNewItem("RequiredProjects", Path.Combine(m_stubsPath, m_nativeProjectFile));

                proj.Save(file);
            }
            catch(Exception e)
            {
                Log.LogError("Error trying to create feature project file \"" + file + "\": " + e.Message);
                result = false;
            }

            return result;
        }
开发者ID:prabby,项目名称:miniclr,代码行数:34,代码来源:CreateInteropFeatureProj.cs

示例2: Execute


//.........这里部分代码省略.........
                new string[] { "$mrversion$", InteractionRenderer.profileId ?? "" }
            };

            // Now we want to scan our assembly for FeatureRenderers
            List<KeyValuePair<FeatureRendererAttribute, IFeatureRenderer>> renderers = new List<KeyValuePair<FeatureRendererAttribute, IFeatureRenderer>>();
            foreach(Type t in this.GetType().Assembly.GetTypes())
                if (t.GetInterface("MohawkCollege.EHR.gpmr.Pipeline.Renderer.RimbaCS.Interfaces.IFeatureRenderer") != null &&
                    t.GetCustomAttributes(typeof(FeatureRendererAttribute), true).Length > 0)
                {
                    foreach(FeatureRendererAttribute feature in (t.GetCustomAttributes(typeof(FeatureRendererAttribute), true)))
                    {
                            // Only one feature renderer per feature, so if the dictionary throws an exception
                            // on the add it is ok
                            renderers.Add(new KeyValuePair<FeatureRendererAttribute,IFeatureRenderer>(feature, (IFeatureRenderer)t.Assembly.CreateInstance(t.FullName)));
                    }
                }

            #region Setup the project
            // Create engine reference
            Microsoft.Build.BuildEngine.Engine engine = new Microsoft.Build.BuildEngine.Engine(
                Path.Combine(Path.Combine(Path.Combine(System.Environment.SystemDirectory, "..\\Microsoft.NET"), "Framework"), "v3.5")),
                phoneEngine = new Microsoft.Build.BuildEngine.Engine(
                Path.Combine(Path.Combine(Path.Combine(System.Environment.SystemDirectory, "..\\Microsoft.NET"), "Framework"), "v4.0.30319"));
            
            // Create MSPROJ
            Microsoft.Build.BuildEngine.Project project = new Microsoft.Build.BuildEngine.Project(engine),
                phoneProj = new Project(phoneEngine, "4.0");

            
            phoneProj.DefaultTargets = project.DefaultTargets = "Build";
            

            // Setup project attributes
            Microsoft.Build.BuildEngine.BuildPropertyGroup pg = project.AddNewPropertyGroup(false);

            Microsoft.Build.BuildEngine.BuildProperty property = pg.AddNewProperty("Configuration", "Release");

            property.Condition = "'$(Configuration)' == ''";
            property = pg.AddNewProperty("Platform", "AnyCPU");
            property.Condition = "'$(Platform)' == ''";
            pg.AddNewProperty("ProductVersion", "10.0.20506");
            pg.AddNewProperty("SchemaVersion", "2.0");
            pg.AddNewProperty("ProjectGuid", Guid.NewGuid().ToString());
            pg.AddNewProperty("OutputType", "Library");
            pg.AddNewProperty("AppDesignerFolder", "Properties");
            pg.AddNewProperty("RootNamespace", parameters["rimbapi-target-ns"][0]);
            pg.AddNewProperty("AssemblyName", parameters["rimbapi-target-ns"][0]);
            
            // Release AnyCPU
            pg = project.AddNewPropertyGroup(false);
            pg.Condition = "'$(Configuration)|$(Platform)' == 'Release|AnyCPU'";
            pg.AddNewProperty("DebugType", "pdbonly");
            pg.AddNewProperty("Optimize", "true");
            pg.AddNewProperty("OutputPath", "bin\\release");
            pg.AddNewProperty("DefineConstants", "TRACE");
            pg.AddNewProperty("ErrorReport", "prompt");
            pg.AddNewProperty("WarningLevel", "4");
            pg.AddNewProperty("DocumentationFile", "bin\\release\\" + parameters["rimbapi-target-ns"][0] + ".xml");

            // Create Dir Structure
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "bin"));
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "lib"));
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "Properties"));
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "Vocabulary"));
            Directory.CreateDirectory(Path.Combine(hostContext.Output, "Interaction"));
开发者ID:oneminot,项目名称:everest,代码行数:66,代码来源:RimbaCsRenderer.cs

示例3: GenerateVCWrapperProject

        /// <summary>
        /// This method generates an XmlDocument representing an MSBuild project wrapper for a VC project
        /// </summary>
        /// <owner>LukaszG</owner>
        static internal XmlDocument GenerateVCWrapperProject(Engine parentEngine, string vcProjectFilename, string toolsVersion)
        {
            string projectPath = Path.GetFullPath(vcProjectFilename);
            Project msbuildProject = null;

            try
            {
                msbuildProject = new Project(parentEngine, toolsVersion);
            }
            catch (InvalidOperationException)
            {
                BuildEventFileInfo fileInfo = new BuildEventFileInfo(projectPath);
                string errorCode;
                string helpKeyword;
                string message = ResourceUtilities.FormatResourceString(out errorCode, out helpKeyword, "UnrecognizedToolsVersion", toolsVersion);
                throw new InvalidProjectFileException(projectPath, fileInfo.Line, fileInfo.Column, fileInfo.EndLine, fileInfo.EndColumn, message, null, errorCode, helpKeyword);
            }

            msbuildProject.IsLoadedByHost = false;
            msbuildProject.DefaultTargets = "Build";

            string wrapperProjectToolsVersion = SolutionWrapperProject.DetermineWrapperProjectToolsVersion(toolsVersion);
            msbuildProject.DefaultToolsVersion = wrapperProjectToolsVersion;

            BuildPropertyGroup propertyGroup = msbuildProject.AddNewPropertyGroup(true /* insertAtEndOfProject = true */);
            propertyGroup.Condition = " ('$(Configuration)' != '') and ('$(Platform)' == '') ";
            propertyGroup.AddNewProperty("ConfigurationName", "$(Configuration)");

            propertyGroup = msbuildProject.AddNewPropertyGroup(true /* insertAtEndOfProject = true */);
            propertyGroup.Condition = " ('$(Configuration)' != '') and ('$(Platform)' != '') ";
            propertyGroup.AddNewProperty("ConfigurationName", "$(Configuration)|$(Platform)");

            // only use PlatformName if we only have the platform part
            propertyGroup = msbuildProject.AddNewPropertyGroup(true /* insertAtEndOfProject = true */);
            propertyGroup.Condition = " ('$(Configuration)' == '') and ('$(Platform)' != '') ";
            propertyGroup.AddNewProperty("PlatformName", "$(Platform)");

            AddVCBuildTarget(msbuildProject, projectPath, "Build", null);
            AddVCBuildTarget(msbuildProject, projectPath, "Clean", "Clean");
            AddVCBuildTarget(msbuildProject, projectPath, "Rebuild", "Rebuild");
            AddVCBuildTarget(msbuildProject, projectPath, "Publish", "Publish");

            // Special environment variable to allow people to see the in-memory MSBuild project generated
            // to represent the VC project.
            if (Environment.GetEnvironmentVariable("MSBuildEmitSolution") != null)
            {
                msbuildProject.Save(vcProjectFilename + ".proj");
            }

            return msbuildProject.XmlDocument;
        }
开发者ID:nikson,项目名称:msbuild,代码行数:55,代码来源:VCWrapperProject.cs

示例4: S3ExistsPrefixProjectFile

        public void S3ExistsPrefixProjectFile()
        {
            if (!IsEmpty)
            {
                string prefix = Guid.NewGuid().ToString();
                string key = prefix + "/jquery.min.js";

                Project project = new Project(Engine.GlobalEngine);
                project.Load("S3Exists.proj");

                BuildPropertyGroup properties = project.AddNewPropertyGroup(false);
                properties.AddNewProperty("Prefix", prefix);
                properties.AddNewProperty("S3AccessKeyId", AccessKeyId);
                properties.AddNewProperty("S3BucketName", BucketName);
                properties.AddNewProperty("S3SecretAccessKeyId", SecretAccessKeyId);
                properties.AddNewProperty("S3UseSsl", UseSsl.ToString());

                project.Build("PrefixExists");

                PutObjectRequest request = new PutObjectRequest()
                    .WithBucketName(BucketName)
                    .WithKey(key)
                    .WithFilePath(@"script\jquery.min.js");

                using (PutObjectResponse response = Client.PutObject(request))
                {
                    cleanupKeys.Add(key);
                }

                project.Build("PrefixExists");
            }
        }
开发者ID:ChadBurggraf,项目名称:tasty,代码行数:32,代码来源:S3ExistsTests.cs

示例5: RemovePropertyGroup

 public void RemovePropertyGroup()
 {
     string mainProjFilename = String.Empty;
     try
     {
         mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(TestData.PropertyGroup);
         Project mainProject = new Project(new Engine());
         BuildPropertyGroup groupToRemove = mainProject.AddNewPropertyGroup(true);
         Assertion.AssertEquals(1, mainProject.PropertyGroups.Count);
         mainProject.RemovePropertyGroup(groupToRemove);
         Assertion.AssertEquals(0, mainProject.PropertyGroups.Count);
     }
     finally
     {
         CompatibilityTestHelpers.RemoveFile(mainProjFilename);
     }
 }
开发者ID:nikson,项目名称:msbuild,代码行数:17,代码来源:Project_Tests.cs

示例6: GetConditionStringForConfiguration

        /// <summary>
        /// Adds a new property group with contents of the given solution configuration to the project
        /// Internal for unit-testing.
        /// </summary>
        /// <param name="msbuildProject"></param>
        /// <param name="solution"></param>
        /// <param name="solutionConfiguration"></param>
        /// <owner>LukaszG</owner>
        static internal void AddPropertyGroupForSolutionConfiguration
        (
            Project msbuildProject, 
            SolutionParser solution,
            ConfigurationInSolution solutionConfiguration
        )
        {
            BuildPropertyGroup propertyGroup = msbuildProject.AddNewPropertyGroup(true /* insertAtEndOfProject = true */);
            propertyGroup.Condition = GetConditionStringForConfiguration(solutionConfiguration);

            StringBuilder solutionConfigurationContents = new StringBuilder("<SolutionConfiguration>");

            // add a project configuration entry for each project in the solution
            foreach (ProjectInSolution project in solution.ProjectsInOrder)
            {
                ProjectConfigurationInSolution projectConfiguration = null;

                if (project.ProjectConfigurations.TryGetValue(solutionConfiguration.FullName, out projectConfiguration))
                {
                    solutionConfigurationContents.AppendFormat(
                        CultureInfo.InvariantCulture,
                        "<ProjectConfiguration Project=\"{0}\">{1}</ProjectConfiguration>",
                        project.ProjectGuid,
                        projectConfiguration.FullName
                    );
                }
            }

            solutionConfigurationContents.Append("</SolutionConfiguration>");

            propertyGroup.AddNewProperty("CurrentSolutionConfigurationContents", solutionConfigurationContents.ToString(), true /* treat as literal */);
        }
开发者ID:nikson,项目名称:msbuild,代码行数:40,代码来源:SolutionWrapperProject.cs

示例7: AddGlobalProperties

        /// <summary>
        /// Adds solution related build event macros and other global properties to the wrapper project
        /// </summary>
        /// <param name="msbuildProject"></param>
        /// <param name="solution"></param>
        /// <owner>LukaszG</owner>
        static private void AddGlobalProperties(Project msbuildProject, SolutionParser solution)
        {
            BuildPropertyGroup propertyGroup = msbuildProject.AddNewPropertyGroup(true /* insertAtEndOfProject = true */);

            string directoryName = solution.SolutionFileDirectory;
            if (!directoryName.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
            {
                directoryName += Path.DirectorySeparatorChar;
            }

            propertyGroup.AddNewProperty("SolutionDir", directoryName, true /* treat as literal */);
            propertyGroup.AddNewProperty("SolutionExt", Path.GetExtension(solution.SolutionFile), true /* treat as literal */);
            propertyGroup.AddNewProperty("SolutionFileName", Path.GetFileName(solution.SolutionFile), true /* treat as literal */);
            propertyGroup.AddNewProperty("SolutionName", Path.GetFileNameWithoutExtension(solution.SolutionFile), true /* treat as literal */);

            propertyGroup.AddNewProperty("SolutionPath", Path.Combine(solution.SolutionFileDirectory, Path.GetFileName(solution.SolutionFile)), true /* treat as literal */);

            // Add other global properties
            BuildPropertyGroup propertyGroup2 = msbuildProject.AddNewPropertyGroup(true /* insertAtEndOfProject = true */);

            // Set the property "TargetFrameworkVersion". This is needed for the GetFrameworkPath target.
            // If TargetFrameworkVersion is already set by the user, use that value.
            // Otherwise if MSBuildToolsVersion is 2.0, use "v2.0"
            // Otherwise if MSBuildToolsVersion is 3.5, use "v3.5"
            // Otherwise use "v4.0".
            BuildProperty v20Property = propertyGroup2.AddNewProperty("TargetFrameworkVersion", "v2.0", true /* treat as literal */);
            BuildProperty v35Property = propertyGroup2.AddNewProperty("TargetFrameworkVersion", "v3.5", true /* treat as literal */);
            BuildProperty v40Property = propertyGroup2.AddNewProperty("TargetFrameworkVersion", "v4.0", true /* treat as literal */);
            v20Property.Condition = "'$(TargetFrameworkVersion)' == '' and '$(MSBuildToolsVersion)' == '2.0'";
            v35Property.Condition = "'$(TargetFrameworkVersion)' == '' and ('$(MSBuildToolsVersion)' == '3.5' or '$(MSBuildToolsVersion)' == '3.0')";
            v40Property.Condition = "'$(TargetFrameworkVersion)' == '' and '$(MSBuildToolsVersion)' == '4.0'";
        }
开发者ID:nikson,项目名称:msbuild,代码行数:38,代码来源:SolutionWrapperProject.cs

示例8: PropertyGroupsGet

 public void PropertyGroupsGet()
 {
     Project p = new Project();
     p.LoadXml(TestData.PropertyGroup);
     p.SetProperty("n", "v");
     p.AddNewPropertyGroup(false);
     BuildPropertyGroupCollection buildPropertyGroups = p.PropertyGroups;
     Assertion.AssertEquals(3, buildPropertyGroups.Count);
     Assertion.AssertEquals(true, buildPropertyGroups.Equals(p.PropertyGroups));
 }
开发者ID:nikson,项目名称:msbuild,代码行数:10,代码来源:Project_Tests.cs

示例9: PrepareProject

        /// <summary>
        /// Prepares the given MSBuild <see cref="Project"/> with properties and items from the given <see cref="GitHubWebhook"/>.
        /// </summary>
        /// <param name="project">The project to prepare.</param>
        /// <param name="hook">The webhook to prepare the project with.</param>
        public static void PrepareProject(Project project, GitHubWebhook hook)
        {
            BuildPropertyGroup properties = project.AddNewPropertyGroup(false);
            properties.AddNewProperty("GitHubAfter", hook.After);
            properties.AddNewProperty("GitHubBefore", hook.Before);
            properties.AddNewProperty("GitHubRef", hook.Ref);
            properties.AddNewProperty("GitHubRepositoryDescription", hook.Repository.Description);
            properties.AddNewProperty("GitHubRepositoryForks", hook.Repository.Forks.ToString(CultureInfo.InvariantCulture));
            properties.AddNewProperty("GitHubRepositoryHomepage", hook.Repository.Homepage);
            properties.AddNewProperty("GitHubRepositoryName", hook.Repository.Name);
            properties.AddNewProperty("GitHubRepositoryOwnerName", hook.Repository.Owner.Name);
            properties.AddNewProperty("GitHubRepositoryOwnerEmail", hook.Repository.Owner.Email);
            properties.AddNewProperty("GitHubRepositoryPlegie", hook.Repository.Plegie);
            properties.AddNewProperty("GitHubRepositoryPrivate", hook.Repository.Private.ToString(CultureInfo.InvariantCulture));
            properties.AddNewProperty("GitHubRepositoryUrl", hook.Repository.Url);
            properties.AddNewProperty("GitHubRepositoryWatchers", hook.Repository.Watchers.ToString(CultureInfo.InvariantCulture));

            BuildItemGroup commits = project.AddNewItemGroup();

            foreach (GitHubWebhookCommit commit in hook.Commits)
            {
                BuildItem item = commits.AddNewItem("GitHubCommit", commit.Url);
                item.SetMetadata("Id", commit.Id);
                item.SetMetadata("Message", commit.Message);
                item.SetMetadata("Timestamp", commit.Timestamp);
                item.SetMetadata("AuthorName", commit.Author.Name);
                item.SetMetadata("AuthorEmail", commit.Author.Email);
            }
        }
开发者ID:ChadBurggraf,项目名称:tasty,代码行数:34,代码来源:GitHubWebhookMSBuildExecuter.cs

示例10: AddNewPropertyGroupAfter

 public void AddNewPropertyGroupAfter()
 {
     Project p = new Project();
     BuildPropertyGroup buildPropertyGroup1 = p.AddNewPropertyGroup(false);
     buildPropertyGroup1.Condition = "true";
     BuildPropertyGroup buildPropertyGroup2 = p.AddNewPropertyGroup(true);
     buildPropertyGroup2.Condition = "false";
     Assertion.AssertEquals(true, p.Xml.IndexOf("<PropertyGroup Condition=\"true\" />") < p.Xml.IndexOf("<PropertyGroup Condition=\"false\" />"));
     Assertion.AssertEquals(2, p.PropertyGroups.Count);
     Assertion.AssertEquals(true, p.IsDirty);
 }
开发者ID:nikson,项目名称:msbuild,代码行数:11,代码来源:Project_Tests.cs

示例11: AddNewPropertyGroupNotAFter

            public void AddNewPropertyGroupNotAFter()
            {
                Project p = new Project();
                p.AddNewImport("p", "c");
                BuildPropertyGroup buildPropertyGroup1 = p.AddNewPropertyGroup(false);

                Assertion.AssertEquals(true, p.Xml.IndexOf("<PropertyGroup />") < p.Xml.IndexOf("<Import Condition=\"c\" Project=\"p\" />"));
            }
开发者ID:nikson,项目名称:msbuild,代码行数:8,代码来源:Project_Tests.cs

示例12: AddNewPropertyGroupBeforeOneOtherPropertyGroupAndAUsingTask

 public void AddNewPropertyGroupBeforeOneOtherPropertyGroupAndAUsingTask()
 {
     Project p = new Project();
     BuildPropertyGroup buildPropertyGroup1 = p.AddNewPropertyGroup(true);
     buildPropertyGroup1.Condition = "true";
     p.AddNewImport("p", "c");
     BuildPropertyGroup buildPropertyGroup2 = p.AddNewPropertyGroup(false);
     buildPropertyGroup2.Condition = "false";
     Assertion.AssertEquals(true, p.Xml.IndexOf("<PropertyGroup Condition=\"true\" />") < p.Xml.IndexOf("<PropertyGroup Condition=\"false\" />"));
     Assertion.AssertEquals(true, p.Xml.IndexOf("<PropertyGroup Condition=\"true\" />") < p.Xml.IndexOf("<Import Condition=\"c\" Project=\"p\" />"));
     Assertion.AssertEquals(2, p.PropertyGroups.Count);
 }
开发者ID:nikson,项目名称:msbuild,代码行数:12,代码来源:Project_Tests.cs

示例13: AddNewPropertyGroup

 public void AddNewPropertyGroup()
 {
     Project p = new Project();
     BuildPropertyGroup buildPropertyGroup = p.AddNewPropertyGroup(true);
     buildPropertyGroup.AddNewProperty("n", "v");
     buildPropertyGroup.Condition = "true";
     Assertion.AssertEquals(true, p.Xml.Contains("<PropertyGroup Condition=\"true\">"));
     Assertion.AssertEquals(1, p.PropertyGroups.Count);
     Assertion.AssertEquals(true, p.IsDirty);
 }
开发者ID:nikson,项目名称:msbuild,代码行数:10,代码来源:Project_Tests.cs

示例14: RemovePropertyGroupsWithMatchingConditionMatchInImported_True

 public void RemovePropertyGroupsWithMatchingConditionMatchInImported_True()
 {
     string importedProjFilename = String.Empty;
     string mainProjFilename = String.Empty;
     try
     {
         importedProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(TestData.PropertyGroup);
         mainProjFilename = ObjectModelHelpers.CreateTempFileOnDisk(TestData.Content3SimpleTargetsDefaultSpecified);
         Project mainProject = new Project(new Engine());
         Project importedProject = new Project(mainProject.ParentEngine);
         mainProject.Load(mainProjFilename);
         importedProject.Load(importedProjFilename);
         BuildPropertyGroup referenceGroup = mainProject.AddNewPropertyGroup(true);
         referenceGroup.Condition = "true";
         mainProject.SetImportedProperty("newp", "newv", "true", importedProject);
         Assertion.AssertEquals(2, mainProject.PropertyGroups.Count);
         mainProject.RemovePropertyGroupsWithMatchingCondition("true", true);
         Assertion.AssertEquals(0, mainProject.PropertyGroups.Count);
     }
     finally
     {
         CompatibilityTestHelpers.RemoveFile(importedProjFilename);
         CompatibilityTestHelpers.RemoveFile(mainProjFilename);
     }
 }
开发者ID:nikson,项目名称:msbuild,代码行数:25,代码来源:Project_Tests.cs

示例15: BuildEventFileInfo

        /// <summary>
        /// Add a PropertyGroup to the project for a particular Asp.Net configuration.  This PropertyGroup
        /// will have the correct values for all the Asp.Net properties for this project and this configuration.
        /// </summary>
        /// <param name="msbuildProject"></param>
        /// <param name="proj"></param>
        /// <param name="configurationName"></param>
        /// <param name="aspNetCompilerParameters"></param>
        /// <param name="solutionFile"></param>
        /// <owner>RGoel</owner>
        static private void AddPropertyGroupForAspNetConfiguration
            (
            Project msbuildProject, 
            ProjectInSolution proj, 
            string configurationName, 
            AspNetCompilerParameters aspNetCompilerParameters,
            string solutionFile
            )
        {
            // Add a new PropertyGroup that is condition'd on the Configuration.
            BuildPropertyGroup newPropertyGroup = msbuildProject.AddNewPropertyGroup(false /* insertAtEndOfProject = false */);
            newPropertyGroup.Condition = String.Format(CultureInfo.InvariantCulture, " '$(AspNetConfiguration)' == '{0}' ", 
                EscapingUtilities.Escape(configurationName));

            // Add properties into the property group for each of the AspNetCompiler properties.
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetVirtualPath"), aspNetCompilerParameters.aspNetVirtualPath, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetPhysicalPath"), aspNetCompilerParameters.aspNetPhysicalPath, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetTargetPath"), aspNetCompilerParameters.aspNetTargetPath, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetForce"), aspNetCompilerParameters.aspNetForce, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetUpdateable"), aspNetCompilerParameters.aspNetUpdateable, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetDebug"), aspNetCompilerParameters.aspNetDebug, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetKeyFile"), aspNetCompilerParameters.aspNetKeyFile, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetKeyContainer"), aspNetCompilerParameters.aspNetKeyContainer, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetDelaySign"), aspNetCompilerParameters.aspNetDelaySign, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetAPTCA"), aspNetCompilerParameters.aspNetAPTCA, true);
            newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetFixedNames"), aspNetCompilerParameters.aspNetFixedNames, true);

            string aspNetPhysicalPath = aspNetCompilerParameters.aspNetPhysicalPath;
            if (!String.IsNullOrEmpty(aspNetPhysicalPath))
            {
                // Trim the trailing slash if one exists.
                if (
                        (aspNetPhysicalPath[aspNetPhysicalPath.Length - 1] == Path.AltDirectorySeparatorChar) ||
                        (aspNetPhysicalPath[aspNetPhysicalPath.Length - 1] == Path.DirectorySeparatorChar)
                    )
                {
                    aspNetPhysicalPath = aspNetPhysicalPath.Substring(0, aspNetPhysicalPath.Length - 1);
                }

                // This gets us the last folder in the physical path.
                string lastFolderInPhysicalPath = null;

                try
                {
                    lastFolderInPhysicalPath = Path.GetFileName(aspNetPhysicalPath);
                }
                catch (Exception e)
                {
                    if (ExceptionHandling.NotExpectedException(e))
                        throw;

                    ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(false,
                        "SubCategoryForSolutionParsingErrors",
                        new BuildEventFileInfo(solutionFile),
                        "SolutionParseInvalidProjectFileName",
                        proj.RelativePath, e.Message);
                }

                if (!String.IsNullOrEmpty(lastFolderInPhysicalPath))
                {
                    // If there is a global property called "OutDir" set, that means the caller is trying to 
                    // override the AspNetTargetPath.  What we want to do in this case is concatenate:
                    //  $(OutDir) + "\_PublishedWebsites" + (the last portion of the folder in the AspNetPhysicalPath).
                    BuildProperty targetPathOverrideProperty = newPropertyGroup.AddNewProperty(GenerateSafePropertyName(proj, "AspNetTargetPath"),
                        @"$(OutDir)" + 
                        EscapingUtilities.Escape(webProjectOverrideFolder) + Path.DirectorySeparatorChar + 
                        EscapingUtilities.Escape(lastFolderInPhysicalPath) + Path.DirectorySeparatorChar);
                    targetPathOverrideProperty.Condition = " '$(OutDir)' != '' ";
                }
            }
        }
开发者ID:nikson,项目名称:msbuild,代码行数:81,代码来源:SolutionWrapperProject.cs


注:本文中的Microsoft.Build.BuildEngine.Project.AddNewPropertyGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。