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


C# Evaluation.ProjectCollection类代码示例

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


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


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