當前位置: 首頁>>代碼示例>>C#>>正文


C# Project.SetProperty方法代碼示例

本文整理匯總了C#中Microsoft.Build.Evaluation.Project.SetProperty方法的典型用法代碼示例。如果您正苦於以下問題:C# Project.SetProperty方法的具體用法?C# Project.SetProperty怎麽用?C# Project.SetProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Build.Evaluation.Project的用法示例。


在下文中一共展示了Project.SetProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PrepareForChecking

        public static void PrepareForChecking(Project proj, string startupObject, IReadOnlyList<string> excludedPaths)
        {
            proj.SetProperty("StartupObject", startupObject);
            proj.SetProperty("OutputType", "Exe");
            proj.SetProperty("UseVSHostingProcess", "false");
            ResolveLinks(proj);
            ExcludePaths(proj, excludedPaths);
        }
開發者ID:kontur-edu,項目名稱:uLearn,代碼行數:8,代碼來源:ProjModifier.cs

示例2: BuildProject

        public static MSbuildResult BuildProject(MsBuildSettings settings, string projectFileName, DirectoryInfo dir)
        {
            var result = new MSbuildResult();
            var path = Path.Combine(dir.FullName, projectFileName);
            var project = new Project(path, null, null, new ProjectCollection());
            project.SetProperty("CscToolPath", settings.CompilerDirectory.FullName);
            var includes = new HashSet<string>(
                project.AllEvaluatedItems
                .Where(i => i.ItemType == "None" || i.ItemType == "Content")
                .Select(i => Path.GetFileName(i.EvaluatedInclude.ToLowerInvariant())));
            foreach (var dll in settings.WellKnownLibsDirectory.GetFiles("*.dll"))
                if (!includes.Contains(dll.Name.ToLowerInvariant()))
                    project.AddItem("None", dll.FullName);
            project.Save();
            using (var stringWriter = new StringWriter())
            {
                var logger = new ConsoleLogger(LoggerVerbosity.Minimal, stringWriter.Write, color => { }, () => { });
                result.Success = SyncBuild(project, logger);
                if (result.Success)
                    result.PathToExe = Path.Combine(project.DirectoryPath,
                                                    project.GetPropertyValue("OutputPath"),
                                                    project.GetPropertyValue("AssemblyName") + ".exe");
                else
                    result.ErrorMessage = stringWriter.ToString();
                return result;
            }
        }
開發者ID:kontur-edu,項目名稱:uLearn,代碼行數:27,代碼來源:MsBuildRunner.cs

示例3: ProjectGetter

        public void ProjectGetter()
        {
            Project project = new Project();
            ProjectProperty property = project.SetProperty("p", "v");

            Assert.Equal(true, Object.ReferenceEquals(project, property.Project));
        }
開發者ID:cameron314,項目名稱:msbuild,代碼行數:7,代碼來源:ProjectProperty_Tests.cs

示例4: AddConfigurations

        public static Project AddConfigurations(Project proj, string defaultConfig)
        {
            try {
                var prop = proj.SetProperty("Configuration", defaultConfig);
                prop.Xml.Condition = " '$(Configuration)' == '' ";

                var debugPropGroup = proj.Xml.AddPropertyGroup();
                var releasePropGroup = proj.Xml.AddPropertyGroup();

                debugPropGroup.Condition = " '$(Configuration)' == 'Release' ";
                debugPropGroup.SetProperty("OutputPath", "bin\\Release");
                debugPropGroup.SetProperty("DebugSymbols", "Fasle");
                debugPropGroup.SetProperty("DebugType", "None");
                debugPropGroup.SetProperty("Optomize", "True");
                debugPropGroup.SetProperty("CheckForOverflowUnderflow", "False");
                debugPropGroup.SetProperty("DefineConstants", "TRACE");

                releasePropGroup.Condition = " '$(Configuration)' == 'Debug' ";
                releasePropGroup.SetProperty("OutputPath", "bin\\Debug");
                releasePropGroup.SetProperty("DebugSymbols", "True");
                releasePropGroup.SetProperty("DebugType", "Full");
                releasePropGroup.SetProperty("Optomize", "False");
                releasePropGroup.SetProperty("CheckForOverflowUnderflow", "True");
                releasePropGroup.SetProperty("DefineConstants", "DEBUG;TRACE");

                return proj;
            } catch {
                throw;
            }
        }
開發者ID:dbug13,項目名稱:dotproject,代碼行數:30,代碼來源:ProjectBuilder.cs

示例5: CreateBuildProject

        void CreateBuildProject()
        {
            string projectPath = Path.Combine(buildDirectory, "content.contentproj");
            string outputPath = Path.Combine(buildDirectory, "bin");

            // Create the build project.
            projectRootElement = ProjectRootElement.Create(projectPath);

            // Include the standard targets file that defines how to build XNA Framework content.
            projectRootElement.AddImport(Application.StartupPath + "\\Exporters\\FBX\\XNA\\XNA Game Studio\\" +
                                         "v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets");

            buildProject = new Project(projectRootElement);

            buildProject.SetProperty("XnaPlatform", "Windows");
            buildProject.SetProperty("XnaProfile", "Reach");
            buildProject.SetProperty("XnaFrameworkVersion", "v4.0");
            buildProject.SetProperty("Configuration", "Release");
            buildProject.SetProperty("OutputPath", outputPath);
            buildProject.SetProperty("ContentRootDirectory", ".");
            buildProject.SetProperty("ReferencePath", Application.StartupPath);

            // Register any custom importers or processors.
            foreach (string pipelineAssembly in pipelineAssemblies)
            {
                buildProject.AddItem("Reference", pipelineAssembly);
            }

            // Hook up our custom error logger.
            errorLogger = new ErrorLogger();

            buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection)
                                  {Loggers = new ILogger[] {errorLogger}};
        }
開發者ID:nicolasmassouh,項目名稱:Babylon.js,代碼行數:34,代碼來源:ContentBuilder.cs

示例6: addPostBuildEvent

 private static void addPostBuildEvent(string path)
 {
     Project project = new Project(path);
     project.SetProperty("PostBuildEvent",
                         string.Format(
                             @"""{0}"" "" $(TargetDir) "" "" $(TargetName) "" "" $(SolutionDir) """,
                             Process.GetCurrentProcess().MainModule.FileName));
     project.Save();
 }
開發者ID:fresky,項目名稱:BuildZipper,代碼行數:9,代碼來源:BuildZipper.cs

示例7: AddGuid

 public static Project AddGuid(Project proj)
 {
     try {
         var guid = string.Format("{{{0}}}", Guid.NewGuid().ToString().ToUpper());
         proj.SetProperty("ProjectGuid", guid);
         return proj;
     } catch {
         throw;
     }
 }
開發者ID:dbug13,項目名稱:dotproject,代碼行數:10,代碼來源:ProjectBuilder.cs

示例8: CompileClassifier

        /// <summary>
        /// Creates a DecisionTreeClassifier.exe from a decision tree, returning the file path of the new exe
        /// </summary>
        public static string CompileClassifier(TreeNode decisionTree)
        {
            var assemblyLocation = Assembly.GetExecutingAssembly().Location;
            var assemblyDirectory = new FileInfo(assemblyLocation).DirectoryName ?? "";

            var classifierDir = Path.Combine(assemblyDirectory, "DecisionTreeClassifier");

            var projFullPath = Path.Combine(classifierDir, "DecisionTreeClassifier.csproj");
            var mainFullPath = Path.Combine(classifierDir, "Program.cs");

            ReplaceSerializedTreeLine(mainFullPath, decisionTree);

            // load up the classifier project
            var proj = new Project(projFullPath);

            // set project to compile special DecisionTree config
            proj.SetProperty("Configuration", "DecisionTree");

            // set the output path
            proj.SetProperty("DecisionTreeOutputPath", assemblyDirectory);

            // make a logger to catch possible build errors
            var logger = new SimpleBuildLogger();

            // if we failed to build the classifier, we're screwed
            if (!proj.Build(logger))
            {
                var sb = new StringBuilder();
                sb.AppendLine("***************************************");
                sb.AppendLine("**** Failed To Compile Classifier! ****");
                sb.AppendLine("***************************************");
                foreach (var error in logger.Errors)
                {
                    sb.AppendLine(error.Message + " " + error.File + ": " + error.LineNumber);
                }
                throw new Exception(sb.ToString());
            }

            // return the executable name
            var exeFileName = proj.GetProperty("AssemblyName").EvaluatedValue + ".exe";
            return Path.Combine(assemblyDirectory, exeFileName);
        }
開發者ID:aldenquimby,項目名稱:cs4701,代碼行數:45,代碼來源:Compiler.cs

示例9: Save

        public MSBuild.Project Save(MSBuild.ProjectCollection collection, string location) {
            location = Path.Combine(location, _name);
            Directory.CreateDirectory(location);

            var project = new MSBuild.Project(collection);
            string projectFile = Path.Combine(location, _name) + ProjectType.ProjectExtension;
            if (_isUserProject) {
                projectFile += ".user";
            }
            project.Save(projectFile);

            if (ProjectType != ProjectType.Generic) {
                var projGuid = Guid;
                project.SetProperty("ProjectTypeGuid", TypeGuid.ToString());
                project.SetProperty("Name", _name);
                project.SetProperty("ProjectGuid", projGuid.ToString("B"));
                project.SetProperty("SchemaVersion", "2.0");
                var group = project.Xml.AddPropertyGroup();
                group.Condition = " '$(Configuration)' == 'Debug' ";
                group.AddProperty("DebugSymbols", "true");
                group = project.Xml.AddPropertyGroup();
                group.Condition = " '$(Configuration)' == 'Release' ";
                group.AddProperty("DebugSymbols", "false");
            }

            foreach (var processor in ProjectType.Processors) {
                processor.PreProcess(project);
            }

            foreach (var item in Items) {
                item.Generate(ProjectType, project);
            }

            foreach (var processor in ProjectType.Processors) {
                processor.PostProcess(project);
            }

            project.Save();

            return project;
        }
開發者ID:CforED,項目名稱:Node.js-Tools-for-Visual-Studio,代碼行數:41,代碼來源:ProjectDefinition.cs

示例10: AddPlatform

        public static Project AddPlatform(Project proj, string platformName)
        {
            try {
                var prop = proj.SetProperty("Platform", platformName);
                prop.Xml.Condition = " '$(Platform)' == '' ";

                var propGroup = proj.Xml.AddPropertyGroup();
                propGroup.Condition = string.Format(" '$(Platform)' == '{0}' ", platformName);
                propGroup.SetProperty("PlatformGroup", platformName);
                return proj;
            } catch {
                throw;
            }
        }
開發者ID:dbug13,項目名稱:dotproject,代碼行數:14,代碼來源:ProjectBuilder.cs

示例11: Single

        public void Single()
        {
            Project project = new Project();
            project.SetProperty("p", "v1");
            StringWriter writer = new StringWriter();

            project.SaveLogicalProject(writer);

            string expected = ObjectModelHelpers.CleanupFileContents(
    @"<?xml version=""1.0"" encoding=""utf-16""?>
<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <PropertyGroup>
    <p>v1</p>
  </PropertyGroup>
</Project>");

            Helpers.VerifyAssertLineByLine(expected, writer.ToString());
        }
開發者ID:nikson,項目名稱:msbuild,代碼行數:18,代碼來源:Preprocessor_Tests.cs

示例12: ContentProject

        public ContentProject(string outputPath, string projectDir = null)
        {
            var rootElement = ProjectRootElement.Create();
            rootElement.AddImport(Path.GetFullPath("lib\\Microsoft.Xna.GameStudio.ContentPipeline.targets"));

            buildProject = new Project(rootElement);
            buildProject.SetProperty("XnaPlatform", "Windows");
            buildProject.SetProperty("XnaProfile", "Reach");
            buildProject.SetProperty("XnaFrameworkVersion", "v4.0");
            buildProject.SetProperty("Configuration", "Release");
            buildProject.SetProperty("OutputPath", outputPath);

            if (!projectDir.IsNullOrEmpty())
                buildProject.SetProperty("BaseIntermediateOutputPath", projectDir.GetRelativePathFrom(Directory.GetCurrentDirectory()));

            errorLogger = new ConfigurableForwardingLogger
            {
                BuildEventRedirector = new NlogEventRedirector()
            };
            buildParams = new BuildParameters(ProjectCollection.GlobalProjectCollection);
            buildParams.Loggers = new ILogger[] { errorLogger };
        }
開發者ID:Rfvgyhn,項目名稱:Gnomoria.ContentExtractor,代碼行數:22,代碼來源:ContentProject.cs

示例13: RenameItem_NewNameContainsItemExpression

        public void RenameItem_NewNameContainsItemExpression()
        {
            Project project = new Project();
            project.SetProperty("p", "v1");
            project.AddItem("h", "h1");
            project.AddItem("i", "i1");
            project.ReevaluateIfNecessary();

            ProjectItem item = Helpers.GetLast(project.Items);

            item.Rename("@(h)");

            Assert.Equal("@(h)", item.UnevaluatedInclude);

            // Rename should have been expanded in this simple case
            Assert.Equal("h1", item.EvaluatedInclude);

            // The ProjectItemElement should be the same
            ProjectItemElement newItemElement = Helpers.GetLast((Helpers.GetLast(project.Xml.ItemGroups)).Items);
            Assert.Equal(true, Object.ReferenceEquals(item.Xml, newItemElement));
        }
開發者ID:cdmihai,項目名稱:msbuild,代碼行數:21,代碼來源:DefinitionEditing_Tests.cs

示例14: AddItem_IncludeContainsPropertyExpression

        public void AddItem_IncludeContainsPropertyExpression()
        {
            Project project = new Project();
            project.SetProperty("p", "v1");
            project.ReevaluateIfNecessary();

            project.AddItem("i", "$(p)");

            Assert.Equal("$(p)", Helpers.GetFirst(project.Items).UnevaluatedInclude);
            Assert.Equal("v1", Helpers.GetFirst(project.Items).EvaluatedInclude);
        }
開發者ID:cdmihai,項目名稱:msbuild,代碼行數:11,代碼來源:DefinitionEditing_Tests.cs

示例15: AddItem_MatchesWildcardWithPropertyReference

        public void AddItem_MatchesWildcardWithPropertyReference()
        {
            Project project = new Project();
            project.SetProperty("p", "xxx");
            project.Xml.AddItem("i", "a;*.$(p);b");
            project.ReevaluateIfNecessary();

            project.AddItem("i", "i1.xxx");

            string expected = ObjectModelHelpers.CleanupFileContents(
    @"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
  <PropertyGroup>
    <p>xxx</p>
  </PropertyGroup>
  <ItemGroup>
    <i Include=""a;*.$(p);b"" />
  </ItemGroup>
</Project>");

            Helpers.VerifyAssertProjectContent(expected, project);
        }
開發者ID:cdmihai,項目名稱:msbuild,代碼行數:21,代碼來源:DefinitionEditing_Tests.cs


注:本文中的Microsoft.Build.Evaluation.Project.SetProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。