• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Evaluation.ProjectCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Build.Evaluation.ProjectCollection的典型用法代码示例。如果您正苦于以下问题:C# ProjectCollection类的具体用法?C# ProjectCollection怎么用?C# ProjectCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProjectCollection类属于Microsoft.Build.Evaluation命名空间,在下文中一共展示了ProjectCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ProjectProcessor

		public ProjectProcessor(string path)
		{
			using (ProjectCollection pc = new ProjectCollection())
			{
				this.Project = pc.GetLoadedProjects(path).FirstOrDefault();
			}
		}
开发者ID:tomgrv,项目名称:PA.InnoSetupProcessor,代码行数:7,代码来源:ProjectProcessor.cs


示例2: Start

        public static string Start(DotnetBuildParams objBuildParams)
        {
            try
            {
                ProjectCollection pc = new ProjectCollection();

                pc.DefaultToolsVersion = "4.0";
                Dictionary<string, string> GlobalProperty = new Dictionary<string, string>();

                GlobalProperty.Add("Configuration", objBuildParams.Configuration);

                GlobalProperty.Add("Platform", objBuildParams.Platform);

                //Here, we set the property

                GlobalProperty.Add("OutputPath", objBuildParams.OutputPath);

                BuildRequestData BuidlRequest = new BuildRequestData(objBuildParams.projectFileName, GlobalProperty, null, objBuildParams.TargetsToBuild, null);

                BuildResult buildResult = BuildManager.DefaultBuildManager.Build(new BuildParameters(pc), BuidlRequest);

                return  ((BuildResultCode)buildResult.OverallResult).ToString();

            }
            catch (Exception ex)
            {
                return BuildResultCode.Failure.ToString() ;
            }
            finally
            {

            }
        }
开发者ID:RKishore222,项目名称:TestProject,代码行数:33,代码来源:Build.cs


示例3: ReloadScripts

        /// <summary>
        /// 
        /// </summary>
        public static bool ReloadScripts()
        {
            if (SceneManager.GameProject == null) return false;

            string projectFileName = SceneManager.GameProject.ProjectPath + @"\Scripts.csproj";
            string tmpProjectFileName = SceneManager.GameProject.ProjectPath + @"\_Scripts.csproj";
            string hash = string.Empty;

            hash = GibboHelper.EncryptMD5(DateTime.Now.ToString());

            try
            {
                /* Change the assembly Name */
                XmlDocument doc = new XmlDocument();
                doc.Load(projectFileName);
                doc.GetElementsByTagName("Project").Item(0).ChildNodes[0]["AssemblyName"].InnerText = hash;
                doc.Save(tmpProjectFileName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            /* Compile project */
            ProjectCollection projectCollection = new ProjectCollection();
            Dictionary<string, string> GlobalProperty = new Dictionary<string, string>();
            GlobalProperty.Add("Configuration", SceneManager.GameProject.Debug ? "Debug" : "Release");
            GlobalProperty.Add("Platform", "x86");

            BuildRequestData buildRequest = new BuildRequestData(tmpProjectFileName, GlobalProperty, null, new string[] { "Build" }, null);
            BuildResult buildResult = BuildManager.DefaultBuildManager.Build(new BuildParameters(projectCollection), buildRequest);

            Console.WriteLine(buildResult.OverallResult);

            string cPath = SceneManager.GameProject.ProjectPath + @"\bin\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + hash + ".dll";

            if (File.Exists(cPath))
            {
                /* read assembly to memory without locking the file */
                byte[] readAllBytes = File.ReadAllBytes(cPath);
                SceneManager.ScriptsAssembly = Assembly.Load(readAllBytes);

                if (SceneManager.ActiveScene != null)
                {
                    SceneManager.ActiveScene.SaveComponentValues();
                    SceneManager.ActiveScene.Initialize();
                }

                Console.WriteLine("Path: " + SceneManager.ScriptsAssembly.GetName().Name);
            }
            else
            {
                File.Delete(tmpProjectFileName);
                return false;
            }

            File.Delete(tmpProjectFileName);

            return true;
        }
开发者ID:TyrelBaux,项目名称:Gibbo2D,代码行数:63,代码来源:ScriptsBuilder.cs


示例4: BuildAsync

    internal static async Task<BuildResult> BuildAsync(this BuildManager buildManager, ITestOutputHelper logger, ProjectCollection projectCollection, ProjectRootElement project, string target, IDictionary<string, string> globalProperties = null, LoggerVerbosity logVerbosity = LoggerVerbosity.Detailed, ILogger[] additionalLoggers = null)
    {
        Requires.NotNull(buildManager, nameof(buildManager));
        Requires.NotNull(projectCollection, nameof(projectCollection));
        Requires.NotNull(project, nameof(project));

        globalProperties = globalProperties ?? new Dictionary<string, string>();
        var projectInstance = new ProjectInstance(project, globalProperties, null, projectCollection);
        var brd = new BuildRequestData(projectInstance, new[] { target }, null, BuildRequestDataFlags.ProvideProjectStateAfterBuild);

        var parameters = new BuildParameters(projectCollection);

        var loggers = new List<ILogger>();
        loggers.Add(new ConsoleLogger(logVerbosity, s => logger.WriteLine(s.TrimEnd('\r', '\n')), null, null));
        loggers.AddRange(additionalLoggers);
        parameters.Loggers = loggers.ToArray();

        buildManager.BeginBuild(parameters);

        var result = await buildManager.BuildAsync(brd);

        buildManager.EndBuild();

        return result;
    }
开发者ID:azeno,项目名称:Nerdbank.GitVersioning,代码行数:25,代码来源:MSBuildExtensions.cs


示例5: BuildIntegrationTests

    public BuildIntegrationTests(ITestOutputHelper logger)
        : base(logger)
    {
        int seed = (int)DateTime.Now.Ticks;
        this.random = new Random(seed);
        this.Logger.WriteLine("Random seed: {0}", seed);
        this.buildManager = new BuildManager();
        this.projectCollection = new ProjectCollection();
        this.projectDirectory = Path.Combine(this.RepoPath, "projdir");
        Directory.CreateDirectory(this.projectDirectory);
        this.LoadTargetsIntoProjectCollection();
        this.testProject = this.CreateProjectRootElement(this.projectDirectory, "test.proj");
        this.testProjectInRoot = this.CreateProjectRootElement(this.RepoPath, "root.proj");
        this.globalProperties.Add("NerdbankGitVersioningTasksPath", Environment.CurrentDirectory + "\\");

        // Sterilize the test of any environment variables.
        foreach (System.Collections.DictionaryEntry variable in Environment.GetEnvironmentVariables())
        {
            string name = (string)variable.Key;
            if (ToxicEnvironmentVariablePrefixes.Any(toxic => name.StartsWith(toxic, StringComparison.OrdinalIgnoreCase)))
            {
                this.globalProperties[name] = string.Empty;
            }
        }
    }
开发者ID:azeno,项目名称:Nerdbank.GitVersioning,代码行数:25,代码来源:BuildIntegrationTests.cs


示例6: SetDefaultToolsVersion

        public void SetDefaultToolsVersion()
        {
            string oldValue = Environment.GetEnvironmentVariable("MSBUILDLEGACYDEFAULTTOOLSVERSION");

            try
            {
                // In the new world of figuring out the ToolsVersion to use, we completely ignore the default
                // ToolsVersion in the ProjectCollection.  However, this test explicitly depends on modifying 
                // that, so we need to turn the new defaulting behavior off in order to verify that this still works.  
                Environment.SetEnvironmentVariable("MSBUILDLEGACYDEFAULTTOOLSVERSION", "1");
                InternalUtilities.RefreshInternalEnvironmentValues();

                ProjectCollection collection = new ProjectCollection();
                collection.AddToolset(new Toolset("x", @"c:\y", collection, null));

                collection.DefaultToolsVersion = "x";

                Assert.AreEqual("x", collection.DefaultToolsVersion);

                string content = @"
                    <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' >
                        <Target Name='t'/>
                    </Project>
                ";

                Project project = new Project(XmlReader.Create(new StringReader(content)), null, null, collection);

                Assert.AreEqual(project.ToolsVersion, "x");
            }
            finally
            {
                Environment.SetEnvironmentVariable("MSBUILDLEGACYDEFAULTTOOLSVERSION", oldValue);
                InternalUtilities.RefreshInternalEnvironmentValues();
            }
        }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:35,代码来源:Project_Internal_Tests.cs


示例7: Build

        public static string[] Build(string solutionFile)
        {
            Console.Error.Write("// Building '{0}'... ", Path.GetFileName(solutionFile));

            var pc = new ProjectCollection();
            var parms = new BuildParameters(pc);
            var globalProperties = new Dictionary<string, string>();
            var request = new BuildRequestData(solutionFile, globalProperties, null, new string[] { "Build" }, null);

            parms.Loggers = new[] {
                new ConsoleLogger(LoggerVerbosity.Quiet)
            };

            var result = BuildManager.DefaultBuildManager.Build(parms, request);
            var resultFiles = new HashSet<string>();

            Console.Error.WriteLine("done.");

            foreach (var kvp in result.ResultsByTarget) {
                var targetResult = kvp.Value;

                if (targetResult.Exception != null)
                    Console.Error.WriteLine("// Compilation failed for target '{0}':\r\n{1}", kvp.Key, targetResult.Exception.Message);
                else {
                    foreach (var filename in targetResult.Items)
                        resultFiles.Add(filename.ItemSpec);
                }
            }

            return resultFiles.ToArray();
        }
开发者ID:nowonu,项目名称:JSIL,代码行数:31,代码来源:SolutionBuilder.cs


示例8: BuildSolution_VS

 private bool BuildSolution_VS()
 {
     if (_SolutionPath == "") return false;
     try
     {
         string projectFilePath = Path.Combine(_SolutionPath);
         _OutputPath = _SolutionPath.Replace(Path.GetFileName(_SolutionPath), "") + "\\bin\\" + BuildInterface_Configuration.Text + "\\";
         ProjectCollection pc = new ProjectCollection();
         Dictionary<string, string> globalProperty = new Dictionary<string, string>();
         globalProperty.Add("OutputPath", _OutputPath);
         BuildParameters bp = new BuildParameters(pc);
         BuildRequestData buildRequest = new BuildRequestData(projectFilePath, globalProperty, "4.0", new string[] { "Build" }, null);
         BuildResult buildResult = BuildManager.DefaultBuildManager.Build(bp, buildRequest);
         if (buildResult.OverallResult == BuildResultCode.Success)
         {
             return true;
         }
         else
         {
             MessageBox.Show("There Are Errors", "Error");
         }
     }
     catch
     {
         MessageBox.Show("Build Failed Unexpectedly", "Error");
     }
     return false;
 }
开发者ID:DeinVenteD,项目名称:Project_ShaDE,代码行数:28,代码来源:MainForm.cs


示例9: buildProject

        public static bool buildProject(this string projectFile, bool redirectToConsole = false)
        {
            try
            {
                var fileLogger = new FileLogger();
                var logFile = projectFile.directoryName().pathCombine(projectFile.fileName() + ".log");
                fileLogger.field("logFileName", logFile);
                if (logFile.fileExists())
                    logFile.file_Delete();

                var projectCollection = new ProjectCollection();
                var project = projectCollection.LoadProject(projectFile);
                if (project.isNull())
                {
                    "could not load project file: {0}".error(projectFile);
                    return false;
                }
                if (redirectToConsole)
                    projectCollection.RegisterLogger(new ConsoleLogger());

                projectCollection.RegisterLogger(fileLogger);
                var result = project.Build();
                fileLogger.Shutdown();
                return result;
            }
            catch(Exception ex)
            {
                ex.log();
                return false;
            }
        }
开发者ID:njmube,项目名称:FluentSharp,代码行数:31,代码来源:Package_Scripts_ExtensionMethods.cs


示例10: VsProject

 /// <summary>Initializes a new instance of the <see cref="VsProject" /> class.</summary>
 /// <param name="filePath">The file path.</param>
 /// <param name="projectCollection">The project collection.</param>
 /// <exception cref="InvalidProjectFileException">The project file could not be found.</exception>
 private VsProject(string filePath, ProjectCollection projectCollection)
     : base(filePath)
 {
     Project = projectCollection.LoadProject(filePath);
     Solutions = new ObservableCollection<VsSolution>();
     LoadNuSpecFile(filePath);
 }
开发者ID:sggeng,项目名称:MyToolkit,代码行数:11,代码来源:VsProject.cs


示例11: CleanWithoutBuild

 public void CleanWithoutBuild()
 {
     AssertBuildEnviromentIsClean(@"MSBuild\Trivial");
     var proj = new ProjectCollection().LoadProject(@"MSBuild\Trivial\trivial.rsproj");
     AssertBuildsProject(proj, "Clean");
     AssertBuildEnviromentIsClean(@"MSBuild\Trivial");
 }
开发者ID:jonyee,项目名称:VisualRust,代码行数:7,代码来源:Project.cs


示例12: Main

        private static void Main()
        {
            try
            {
                // Run this in debug otherwise the files in CreateInstallers will be locked. :)
                const string projectFileName = @"..\..\..\wix-custom-ba-issue.sln";
                var pc = new ProjectCollection();
                var globalProperty = new Dictionary<string, string> {{"Configuration", "Release"}};

                var buildRequestData = new BuildRequestData(projectFileName, globalProperty, null, new[] {"Rebuild"},
                    null);

                var buildParameters = new BuildParameters(pc)
                {
                    DetailedSummary = true,
                    Loggers = new List<ILogger> {new ConsoleLogger()}
                };

                foreach (var version in new List<string> {"0.0.6.0", "1.0.0.0"})
                    BuildExamples(version, buildParameters, buildRequestData);
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed!", e);
                Console.WriteLine(e.ToString());
            }
        }
开发者ID:squirmy,项目名称:wix-custom-ba-issue,代码行数:27,代码来源:Program.cs


示例13: AddSolutionConfiguration

    static void AddSolutionConfiguration(string projectFile, Dictionary<string, string> properties)
    {
        var collection = new ProjectCollection(properties);
        var toolsVersion = default(string);
        var project = new Project(projectFile, properties, toolsVersion, collection);
        var config = project.GetPropertyValue("Configuration");
        var platform = project.GetPropertyValue("Platform");

        var xml = new XElement("SolutionConfiguration");
        xml.Add(new XElement("ProjectConfiguration",
            new XAttribute("Project", project.GetPropertyValue("ProjectGuid")),
            new XAttribute("AbsolutePath", project.FullPath),
            new XAttribute("BuildProjectInSolution", "true"))
        {
            Value = $"{config}|{platform}"
        });

        foreach (var reference in GetProjectReferences(project))
        {
            xml.Add(new XElement("ProjectConfiguration",
                new XAttribute("Project", reference.GetPropertyValue("ProjectGuid")),
                new XAttribute("AbsolutePath", reference.FullPath),
                new XAttribute("BuildProjectInSolution", "false"))
            {
                Value = $"{config}|{platform}"
            });
        }

        properties["CurrentSolutionConfigurationContents"] = xml.ToString(SaveOptions.None);
    }
开发者ID:xamarin,项目名称:NuGetizer3000,代码行数:30,代码来源:Builder.cs


示例14: BuildProject

        private static void BuildProject(string projectFile)
        {
            Console.WriteLine("Building Project [" + projectFile + "]");
            var collection = new ProjectCollection {DefaultToolsVersion = "12.0"};
            collection.LoadProject(projectFile);

            collection.RegisterLoggers(new List<ILogger> { new ConsoleLogger(), new FileLogger {Parameters = projectFile + ".build.log"}});

            try
            {
                foreach (var project in collection.LoadedProjects.Where(x => x.IsBuildEnabled))
                {
                    project.SetProperty("Platform", "x64");
                    if (!project.Build())
                        throw new BuildException(projectFile);

                    project.SetProperty("Configuration", "Release");
                    if (!project.Build())
                        throw new BuildException(projectFile);
                }
            }
            finally
            {
                collection.UnregisterAllLoggers();
            }
        }
开发者ID:kaylynb,项目名称:Sunflower,代码行数:26,代码来源:Program.cs


示例15: PublishSite

        private void PublishSite(Dictionary<string, string> properties)
        {
            var logFile = Path.GetTempFileName();

            try
            {
                bool success;
                using (var projects = new ProjectCollection(properties))
                {
                    projects.RegisterLogger(new FileLogger { Parameters = @"logfile=" + logFile, Verbosity = LoggerVerbosity.Quiet });
                    projects.OnlyLogCriticalEvents = true;
                    var project = projects.LoadProject(ProjectPath);
                    success = project.Build();
                }

                if (!success)
                {
                    Console.WriteLine(File.ReadAllText(logFile));
                    throw new ApplicationException("Build failed.");
                }
            }
            finally
            {
                if (File.Exists(logFile))
                {
                    File.Delete(logFile);
                }
            }
        }
开发者ID:bigjump,项目名称:SpecsFor,代码行数:29,代码来源:IISTestRunnerAction.cs


示例16: ProjectBuilder

		public ProjectBuilder (BuildEngine buildEngine, ProjectCollection engine, string file)
		{
			this.file = file;
			this.engine = engine;
			this.buildEngine = buildEngine;
			Refresh ();
		}
开发者ID:riverans,项目名称:monodevelop,代码行数:7,代码来源:ProjectBuilder.v4.0.cs


示例17: BuildProject

        /// <summary>
        /// Builds the project - based on http://msdn.microsoft.com/en-us/library/microsoft.build.buildengine.engine.aspx.
        /// </summary>
        /// <param name="projectPath">The project (csproj) path</param>
        /// <returns>True if builds okay</returns>
        private static bool BuildProject(string projectPath)
        {
            var logPath = Path.Combine(Path.GetDirectoryName(projectPath), "build.log");

            //.Net 4 Microsoft.Build.Evaluation.Project and ProjectCollection
            var engine = new ProjectCollection();

            // Instantiate a new FileLogger to generate build log
            var logger = new Microsoft.Build.Logging.FileLogger();

            // Set the logfile parameter to indicate the log destination
            logger.Parameters = @"logfile=" + logPath;

            // Register the logger with the engine
            engine.RegisterLogger(logger);

            // Build a project file
            bool success = engine.LoadProject(projectPath).Build();
            //Unregister all loggers to close the log file
            engine.UnregisterAllLoggers();

            //if fails, put the log file into the assert statement
            string txt = "Should have built";
            if (!success && File.Exists(logPath))
                txt = File.ReadAllText(logPath);
            Console.WriteLine(txt);

            return success;
        }
开发者ID:shiningrise,项目名称:dbschemareader,代码行数:34,代码来源:CodeWriterBuildTest.cs


示例18: ImportFromExtensionsPathNotFound

        public void ImportFromExtensionsPathNotFound()
        {
            string extnDir1 = null;
            string mainProjectPath = null;

            try {
                extnDir1 = GetNewExtensionsPathAndCreateFile("extensions1", Path.Combine("foo", "extn.proj"), GetExtensionTargetsFileContent1());
                mainProjectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("main.proj", GetMainTargetFileContent());

                var projColln = new ProjectCollection();
                projColln.ResetToolsetsForTests(WriteConfigFileAndGetReader("MSBuildExtensionsPath", extnDir1, Path.Combine("tmp", "nonexistant")));
                var logger = new MockLogger();
                projColln.RegisterLogger(logger);

                Assert.Throws<InvalidProjectFileException>(() => projColln.LoadProject(mainProjectPath));

                logger.AssertLogContains("MSB4226");
            } finally {
                if (mainProjectPath != null)
                {
                    FileUtilities.DeleteNoThrow(mainProjectPath);
                }
                if (extnDir1 != null)
                {
                    FileUtilities.DeleteDirectoryNoThrow(extnDir1, recursive: true);
                }
            }
        }
开发者ID:cdmihai,项目名称:msbuild,代码行数:28,代码来源:ImportFromMSBuildExtensionsPath_Tests.cs


示例19: BuildTrivialProject

 public void BuildTrivialProject()
 {
     var proj = new ProjectCollection().LoadProject(@"MSBuild\Trivial\trivial.rsproj");
     AssertBuildsProject(proj, "Build");
     Assert.IsTrue(File.Exists(@"MSBuild\Trivial\target\Debug\trivial.exe"));
     Directory.Delete(@"MSBuild\Trivial\obj", true);
     Directory.Delete(@"MSBuild\Trivial\target", true);
 }
开发者ID:jonyee,项目名称:VisualRust,代码行数:8,代码来源:Project.cs


示例20: ProjectBuilder

		public ProjectBuilder (BuildEngine buildEngine, ProjectCollection engine, string file)
		{
			this.file = file;
			this.engine = engine;
			this.buildEngine = buildEngine;
			consoleLogger = new ConsoleLogger (LoggerVerbosity.Normal, LogWriteLine, null, null);
			Refresh ();
		}
开发者ID:llucenic,项目名称:monodevelop,代码行数:8,代码来源:ProjectBuilder.v4.0.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Evaluation.ProjectItem类代码示例发布时间:2022-05-26
下一篇:
C# Evaluation.Project类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap