当前位置: 首页>>代码示例>>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;未经允许,请勿转载。