/// <summary> /// Initializes a build request with a parent context. /// </summary> /// <param name="submissionId">The id of the build submission.</param> /// <param name="nodeRequestId">The id of the node issuing the request</param> /// <param name="configurationId">The configuration id to use.</param> /// <param name="escapedTargets">The targets to be built</param> /// <param name="hostServices">Host services if any. May be null.</param> /// <param name="parentBuildEventContext">The build event context of the parent project.</param> /// <param name="parentRequest">The parent build request, if any.</param> /// <param name="buildRequestDataFlags">Additional flags for the request.</param> /// <param name="requestedProjectState">Filter for desired build results.</param> public BuildRequest( int submissionId, int nodeRequestId, int configurationId, ICollection <string> escapedTargets, HostServices hostServices, BuildEventContext parentBuildEventContext, BuildRequest parentRequest, BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None, RequestedProjectState requestedProjectState = null) { ErrorUtilities.VerifyThrowArgumentNull(escapedTargets, "targets"); ErrorUtilities.VerifyThrowArgumentNull(parentBuildEventContext, "parentBuildEventContext"); _submissionId = submissionId; _configurationId = configurationId; // When targets come into a build request, we unescape them. _targets = new List <string>(escapedTargets.Count); foreach (string target in escapedTargets) { _targets.Add(EscapingUtilities.UnescapeAll(target)); } HostServices = hostServices; _buildEventContext = BuildEventContext.Invalid; _parentBuildEventContext = parentBuildEventContext; _globalRequestId = InvalidGlobalRequestId; _parentGlobalRequestId = parentRequest?.GlobalRequestId ?? InvalidGlobalRequestId; _nodeRequestId = nodeRequestId; _buildRequestDataFlags = buildRequestDataFlags; _requestedProjectState = requestedProjectState; }
internal void Build(Project project, string targets, BuildRequestDataFlags flags, Microsoft.Build.Utilities.Logger logger) { if (project is null) { throw new ArgumentNullException(nameof(project)); } if (logger is null) { throw new ArgumentNullException(nameof(logger)); } // Make sure that we are using the project collection from the loaded project, otherwise we are getting // weird cache behavior with the MSBuild system var projectInstance = new ProjectInstance(project.Xml, project.ProjectCollection.GlobalProperties, project.ToolsVersion, project.ProjectCollection); BuildTask = Task.Run(() => { var buildResult = mainBuildManager.Build( new BuildParameters(project.ProjectCollection) { Loggers = new[] { logger } }, new BuildRequestData(projectInstance, targets.Split(';'), null, flags)); return(buildResult); }); }
public BuildRequest( int submissionId, int nodeRequestId, int configurationId, ICollection <string> escapedTargets, HostServices hostServices, BuildEventContext parentBuildEventContext, BuildRequest parentRequest, BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None, RequestedProjectState requestedProjectState = null, bool skipStaticGraphIsolationConstraints = false, int projectContextId = BuildEventContext.InvalidProjectContextId) : this(submissionId, nodeRequestId, configurationId, hostServices, buildRequestDataFlags, requestedProjectState, projectContextId) { ErrorUtilities.VerifyThrowArgumentNull(escapedTargets, "targets"); ErrorUtilities.VerifyThrowArgumentNull(parentBuildEventContext, nameof(parentBuildEventContext)); // When targets come into a build request, we unescape them. _targets = new List <string>(escapedTargets.Count); foreach (string target in escapedTargets) { _targets.Add(EscapingUtilities.UnescapeAll(target)); } _parentBuildEventContext = parentBuildEventContext; _parentGlobalRequestId = parentRequest?.GlobalRequestId ?? InvalidGlobalRequestId; _skipStaticGraphIsolationConstraints = skipStaticGraphIsolationConstraints; }
/// <summary> /// Common constructor. /// </summary> private BuildRequestData(string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { ErrorUtilities.VerifyThrowArgumentNull(targetsToBuild, nameof(targetsToBuild)); HostServices = hostServices; TargetNames = new List <string>(targetsToBuild); Flags = flags; }
public BuildRequestData(ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { ProjectInstance = projectInstance; TargetNames = targetsToBuild; HostServices = hostServices; Flags = flags; }
public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { ProjectInstance = projectInstance; TargetNames = targetsToBuild; HostServices = hostServices; Flags = flags; }
public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { if (targetsToBuild == null) throw new ArgumentNullException ("targetsToBuild"); ProjectInstance = projectInstance; TargetNames = targetsToBuild; HostServices = hostServices; Flags = flags; }
/// <summary> /// Initializes a build request. /// </summary> /// <param name="config">The configuration to use for the request.</param> /// <param name="targets">The set of targets to build.</param> /// <param name="resultsNeeded">Whether or not to wait for the results of this request.</param> /// <param name="flags">Flags specified for the build request.</param> public FullyQualifiedBuildRequest(BuildRequestConfiguration config, string[] targets, bool resultsNeeded, BuildRequestDataFlags flags = BuildRequestDataFlags.None) { ErrorUtilities.VerifyThrowArgumentNull(config, "config"); ErrorUtilities.VerifyThrowArgumentNull(targets, "targets"); Config = config; Targets = targets; ResultsNeeded = resultsNeeded; BuildRequestDataFlags = flags; }
public BuildRequestData(ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { if (targetsToBuild == null) { throw new ArgumentNullException("targetsToBuild"); } ProjectInstance = projectInstance; TargetNames = targetsToBuild; HostServices = hostServices; Flags = flags; }
/// <summary> /// Common constructor. /// </summary> private GraphBuildRequestData(ICollection <string> targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { ErrorUtilities.VerifyThrowArgumentNull(targetsToBuild, nameof(targetsToBuild)); foreach (string targetName in targetsToBuild) { ErrorUtilities.VerifyThrowArgumentNull(targetName, "target"); } HostServices = hostServices; TargetNames = new List <string>(targetsToBuild); Flags = flags; }
/// <summary> /// Initializes a build request. /// </summary> /// <param name="config">The configuration to use for the request.</param> /// <param name="targets">The set of targets to build.</param> /// <param name="resultsNeeded">Whether or not to wait for the results of this request.</param> /// <param name="skipStaticGraphIsolationConstraints">Whether to skip the constraints of static graph isolation.</param> /// <param name="flags">Flags specified for the build request.</param> public FullyQualifiedBuildRequest( BuildRequestConfiguration config, string[] targets, bool resultsNeeded, bool skipStaticGraphIsolationConstraints = false, BuildRequestDataFlags flags = BuildRequestDataFlags.None ) { ErrorUtilities.VerifyThrowArgumentNull(config, nameof(config)); ErrorUtilities.VerifyThrowArgumentNull(targets, nameof(targets)); Config = config; Targets = targets; ResultsNeeded = resultsNeeded; SkipStaticGraphIsolationConstraints = skipStaticGraphIsolationConstraints; BuildRequestDataFlags = flags; }
public BuildRequest( int submissionId, int nodeRequestId, int configurationId, ProxyTargets proxyTargets, HostServices hostServices, BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None, RequestedProjectState requestedProjectState = null, int projectContextId = BuildEventContext.InvalidProjectContextId) : this(submissionId, nodeRequestId, configurationId, hostServices, buildRequestDataFlags, requestedProjectState, projectContextId) { _proxyTargets = proxyTargets; _targets = proxyTargets.ProxyTargetToRealTargetMap.Keys.ToList(); // Only root requests can have proxy targets. _parentGlobalRequestId = InvalidGlobalRequestId; _parentBuildEventContext = BuildEventContext.Invalid; }
private BuildRequest( int submissionId, int nodeRequestId, int configurationId, HostServices hostServices, BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None, RequestedProjectState requestedProjectState = null) { _submissionId = submissionId; _configurationId = configurationId; HostServices = hostServices; _buildEventContext = BuildEventContext.Invalid; _globalRequestId = InvalidGlobalRequestId; _nodeRequestId = nodeRequestId; _buildRequestDataFlags = buildRequestDataFlags; _requestedProjectState = requestedProjectState; }
/// <summary> /// Executes a build for the specified project. /// </summary> /// <param name="projectInstance">A <see cref="ProjectInstance" /> representing the project.</param> /// <param name="targets">An optional list of targets to execute.</param> /// <param name="globalProperties">An optional <see cref="IDictionary{TKey,TValue}" /> containing global properties to use when building.</param> /// <param name="loggers">An <see cref="IEnumerable{T}" /> containing <see cref="ILogger" /> items to use.</param> /// <param name="buildRequestDataFlags">The <see cref="BuildRequestDataFlags" /> to use.</param> /// <returns>A <see cref="BuildResult" /> containing details about the result of the build.</returns> public static BuildResult Build(ProjectInstance projectInstance, string[] targets, IDictionary <string, string> globalProperties, IEnumerable <ILogger> loggers, BuildRequestDataFlags buildRequestDataFlags) { BuildRequestData buildRequestData = new BuildRequestData( projectInstance, targets ?? Array.Empty <string>(), hostServices: null, buildRequestDataFlags); return(Build(buildRequestData, loggers)); }
/// <summary> /// Constructs a BuildRequestData for build requests based on project files. /// </summary> /// <param name="projectFullPath">The full path to the project file.</param> /// <param name="globalProperties">The global properties which should be used during evaluation of the project. Cannot be null.</param> /// <param name="toolsVersion">The tools version to use for the build. May be null.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use. May be null.</param> /// <param name="flags">The <see cref="BuildRequestDataFlags"/> to use.</param> public BuildRequestData(string projectFullPath, IDictionary <string, string> globalProperties, string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(targetsToBuild, hostServices, flags) { ErrorUtilities.VerifyThrowArgumentLength(projectFullPath, nameof(projectFullPath)); ErrorUtilities.VerifyThrowArgumentNull(globalProperties, nameof(globalProperties)); ProjectFullPath = FileUtilities.NormalizePath(projectFullPath); TargetNames = (ICollection <string>)targetsToBuild.Clone(); GlobalPropertiesDictionary = new PropertyDictionary <ProjectPropertyInstance>(globalProperties.Count); foreach (KeyValuePair <string, string> propertyPair in globalProperties) { GlobalPropertiesDictionary.Set(ProjectPropertyInstance.Create(propertyPair.Key, propertyPair.Value)); } ExplicitlySpecifiedToolsVersion = toolsVersion; }
public BuildRequestData (ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { throw new NotImplementedException (); }
/// <summary> /// Constructs a BuildRequestData for build requests based on project instances. /// </summary> /// <param name="projectInstance">The instance to build.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use, if any. May be null.</param> /// <param name="flags">Flags controlling this build request.</param> /// <param name="propertiesToTransfer">The list of properties whose values should be transferred from the project to any out-of-proc node.</param> /// <param name="requestedProjectState">A <see cref="Execution.RequestedProjectState"/> describing properties, items, and metadata that should be returned. Requires setting <see cref="BuildRequestDataFlags.ProvideSubsetOfStateAfterBuild"/>.</param> public BuildRequestData(ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags, IEnumerable <string> propertiesToTransfer, RequestedProjectState requestedProjectState) : this(projectInstance, targetsToBuild, hostServices, flags, propertiesToTransfer) { ErrorUtilities.VerifyThrowArgumentNull(requestedProjectState, nameof(requestedProjectState)); RequestedProjectState = requestedProjectState; }
/// <summary> /// Constructs a BuildRequestData for build requests based on project files. /// </summary> /// <param name="projectFullPath">The full path to the project file.</param> /// <param name="globalProperties">The global properties which should be used during evaluation of the project. Cannot be null.</param> /// <param name="toolsVersion">The tools version to use for the build. May be null.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use. May be null.</param> /// <param name="flags">The <see cref="BuildRequestDataFlags"/> to use.</param> /// <param name="requestedProjectState">A <see cref="Execution.RequestedProjectState"/> describing properties, items, and metadata that should be returned. Requires setting <see cref="BuildRequestDataFlags.ProvideSubsetOfStateAfterBuild"/>.</param> public BuildRequestData(string projectFullPath, IDictionary <string, string> globalProperties, string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags, RequestedProjectState requestedProjectState) : this(projectFullPath, globalProperties, toolsVersion, targetsToBuild, hostServices, flags) { ErrorUtilities.VerifyThrowArgumentNull(requestedProjectState, nameof(requestedProjectState)); RequestedProjectState = requestedProjectState; }
/// <summary> /// Constructs a GraphBuildRequestData for build requests based on a project graph entry points. /// </summary> /// <param name="projectGraphEntryPoints">The entry points to use in the build.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use, if any. May be null.</param> /// <param name="flags">Flags controlling this build request.</param> public GraphBuildRequestData(IEnumerable <ProjectGraphEntryPoint> projectGraphEntryPoints, ICollection <string> targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(targetsToBuild, hostServices, flags) { ErrorUtilities.VerifyThrowArgumentNull(projectGraphEntryPoints, nameof(projectGraphEntryPoints)); ProjectGraphEntryPoints = projectGraphEntryPoints; }
public BuildRequestData(string projectFullPath, IDictionary <string, string> globalProperties, string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { throw new NotImplementedException(); }
public BuildRequestData (string projectFullPath, IDictionary<string, string> globalProperties, string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { throw new NotImplementedException (); }
public BuildRequestData(string projectFullPath, IDictionary <string, string> globalProperties, string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(new ProjectInstance(projectFullPath, globalProperties, toolsVersion), targetsToBuild, hostServices, flags) { ExplicitlySpecifiedToolsVersion = toolsVersion; }
/// <summary> /// Constructs a BuildRequestData for build requests based on project files. /// </summary> /// <param name="projectFullPath">The full path to the project file.</param> /// <param name="globalProperties">The global properties which should be used during evaluation of the project. Cannot be null.</param> /// <param name="toolsVersion">The tools version to use for the build. May be null.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use. May be null.</param> public BuildRequestData(string projectFullPath, IDictionary<string, string> globalProperties, string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(targetsToBuild, hostServices, flags) { ErrorUtilities.VerifyThrowArgumentLength(projectFullPath, "projectFullPath"); ErrorUtilities.VerifyThrowArgumentNull(globalProperties, "globalProperties"); this.ProjectFullPath = FileUtilities.NormalizePath(projectFullPath); TargetNames = (ICollection<string>)targetsToBuild.Clone(); GlobalPropertiesDictionary = new PropertyDictionary<ProjectPropertyInstance>(globalProperties.Count); foreach (KeyValuePair<string, string> propertyPair in globalProperties) { GlobalPropertiesDictionary.Set(ProjectPropertyInstance.Create(propertyPair.Key, propertyPair.Value)); } ExplicitlySpecifiedToolsVersion = toolsVersion; }
/// <summary> /// Constructs a BuildRequestData for build requests based on project instances. /// </summary> /// <param name="projectInstance">The instance to build.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use, if any. May be null.</param> /// <param name="flags">Flags controlling this build request.</param> /// <param name="propertiesToTransfer">The list of properties whose values should be transferred from the project to any out-of-proc node.</param> public BuildRequestData(ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags, IEnumerable<string> propertiesToTransfer) : this(targetsToBuild, hostServices, flags) { ErrorUtilities.VerifyThrowArgumentNull(projectInstance, "projectInstance"); foreach (string targetName in targetsToBuild) { ErrorUtilities.VerifyThrowArgumentNull(targetName, "target"); } ProjectInstance = projectInstance; ProjectFullPath = projectInstance.FullPath; GlobalPropertiesDictionary = projectInstance.GlobalPropertiesDictionary; ExplicitlySpecifiedToolsVersion = projectInstance.ExplicitToolsVersion; if (propertiesToTransfer != null) { this.PropertiesToTransfer = new List<string>(propertiesToTransfer); } }
/// <summary> /// Common constructor. /// </summary> private BuildRequestData(string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { ErrorUtilities.VerifyThrowArgumentNull(targetsToBuild, "targetsToBuild"); HostServices = hostServices; TargetNames = new List<string>(targetsToBuild); Flags = flags; }
/// <summary> /// Constructs a GraphBuildRequestData for build requests based on a project graph. /// </summary> /// <param name="projectGraph">The graph to build.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use, if any. May be null.</param> /// <param name="flags">Flags controlling this build request.</param> public GraphBuildRequestData(ProjectGraph projectGraph, ICollection <string> targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(targetsToBuild, hostServices, flags) { ErrorUtilities.VerifyThrowArgumentNull(projectGraph, nameof(projectGraph)); ProjectGraph = projectGraph; }
/// <summary> /// Constructs a BuildRequestData for build requests based on project instances. /// </summary> /// <param name="projectInstance">The instance to build.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use, if any. May be null.</param> /// <param name="flags">Flags controlling this build request.</param> public BuildRequestData(ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(projectInstance, targetsToBuild, hostServices, flags, null) { }
/// <summary> /// Initializes a build request with a parent context. /// </summary> /// <param name="submissionId">The id of the build submission.</param> /// <param name="nodeRequestId">The id of the node issuing the request</param> /// <param name="configurationId">The configuration id to use.</param> /// <param name="escapedTargets">The targets to be built</param> /// <param name="hostServices">Host services if any. May be null.</param> /// <param name="parentBuildEventContext">The build event context of the parent project.</param> /// <param name="parentRequest">The parent build request, if any.</param> /// <param name="buildRequestDataFlags">Additional flags for the request.</param> public BuildRequest( int submissionId, int nodeRequestId, int configurationId, ICollection<string> escapedTargets, HostServices hostServices, BuildEventContext parentBuildEventContext, BuildRequest parentRequest, BuildRequestDataFlags buildRequestDataFlags = BuildRequestDataFlags.None) { ErrorUtilities.VerifyThrowArgumentNull(escapedTargets, "targets"); ErrorUtilities.VerifyThrowArgumentNull(parentBuildEventContext, "parentBuildEventContext"); _submissionId = submissionId; _configurationId = configurationId; // When targets come into a build request, we unescape them. _targets = new List<string>(escapedTargets.Count); foreach (string target in escapedTargets) { _targets.Add(EscapingUtilities.UnescapeAll(target)); } _hostServices = hostServices; _buildEventContext = BuildEventContext.Invalid; _parentBuildEventContext = parentBuildEventContext; _globalRequestId = InvalidGlobalRequestId; if (null != parentRequest) { _parentGlobalRequestId = parentRequest.GlobalRequestId; } else { _parentGlobalRequestId = InvalidGlobalRequestId; } _nodeRequestId = nodeRequestId; _buildRequestDataFlags = buildRequestDataFlags; }
public static string GetOrCompileProjectAssembly(string fullProjectLocation, ILogger logger, bool autoCompileProject, string configuration = "Debug", string platform = "AnyCPU", Dictionary <string, string> extraProperties = null, bool onlyErrors = false, BuildRequestDataFlags flags = BuildRequestDataFlags.None) { if (fullProjectLocation == null) { throw new ArgumentNullException("fullProjectLocation"); } if (logger == null) { throw new ArgumentNullException("logger"); } var project = LoadProject(fullProjectLocation, configuration, platform, extraProperties); var assemblyPath = project.GetPropertyValue("TargetPath"); if (!string.IsNullOrWhiteSpace(assemblyPath)) { if (autoCompileProject) { var asyncBuild = new CancellableAsyncBuild(project, assemblyPath); asyncBuild.Build(project, "Build", flags, new LoggerRedirect(logger, onlyErrors)); var buildResult = asyncBuild.BuildTask.Result; } } return(assemblyPath); }
public static ICancellableAsyncBuild CompileProjectAssemblyAsync(string solutionFullPath, string fullProjectLocation, ILogger logger, string targets = "Build", string configuration = "Debug", string platform = "AnyCPU", Dictionary <string, string> extraProperties = null, BuildRequestDataFlags flags = BuildRequestDataFlags.None) { if (fullProjectLocation == null) { throw new ArgumentNullException("fullProjectLocation"); } if (logger == null) { throw new ArgumentNullException("logger"); } var project = LoadProject(fullProjectLocation, configuration, platform, extraProperties); var assemblyPath = project.GetPropertyValue("TargetPath"); try { if (!string.IsNullOrWhiteSpace(assemblyPath)) { var asyncBuild = new CancellableAsyncBuild(project, assemblyPath); asyncBuild.Build(project, targets, flags, new LoggerRedirect(logger)); return(asyncBuild); } } finally { project.ProjectCollection.UnloadAllProjects(); project.ProjectCollection.Dispose(); } return(null); }
/// <summary> /// Constructs a GraphBuildRequestData for build requests based on a project graph entry points. /// </summary> /// <param name="projectGraphEntryPoint">The entry point to use in the build.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use, if any. May be null.</param> /// <param name="flags">Flags controlling this build request.</param> public GraphBuildRequestData(ProjectGraphEntryPoint projectGraphEntryPoint, ICollection <string> targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(projectGraphEntryPoint.AsEnumerable(), targetsToBuild, hostServices, flags) { }
/// <summary> /// Constructs a BuildRequestData for build requests based on project instances. /// </summary> /// <param name="projectInstance">The instance to build.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use, if any. May be null.</param> /// <param name="flags">Flags controlling this build request.</param> public BuildRequestData(ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(projectInstance, targetsToBuild, hostServices, flags, null) { }
/// <summary> /// Constructs a BuildRequestData for build requests based on project instances. /// </summary> /// <param name="projectInstance">The instance to build.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use, if any. May be null.</param> /// <param name="flags">Flags controlling this build request.</param> /// <param name="propertiesToTransfer">The list of properties whose values should be transferred from the project to any out-of-proc node.</param> public BuildRequestData(ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags, IEnumerable <string> propertiesToTransfer) : this(targetsToBuild, hostServices, flags) { ErrorUtilities.VerifyThrowArgumentNull(projectInstance, nameof(projectInstance)); foreach (string targetName in targetsToBuild) { ErrorUtilities.VerifyThrowArgumentNull(targetName, "target"); } ProjectInstance = projectInstance; ProjectFullPath = projectInstance.FullPath; GlobalPropertiesDictionary = projectInstance.GlobalPropertiesDictionary; ExplicitlySpecifiedToolsVersion = projectInstance.ExplicitToolsVersion; if (propertiesToTransfer != null) { PropertiesToTransfer = new List <string>(propertiesToTransfer); } }
/// <summary> /// Constructs a GraphBuildRequestData for build requests based on project files. /// </summary> /// <param name="projectFullPath">The full path to the project file.</param> /// <param name="globalProperties">The global properties which should be used during evaluation of the project. Cannot be null.</param> /// <param name="targetsToBuild">The targets to build.</param> /// <param name="hostServices">The host services to use. May be null.</param> /// <param name="flags">The <see cref="BuildRequestDataFlags"/> to use.</param> public GraphBuildRequestData(string projectFullPath, IDictionary <string, string> globalProperties, ICollection <string> targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this(new ProjectGraphEntryPoint(projectFullPath, globalProperties).AsEnumerable(), targetsToBuild, hostServices, flags) { }
public BuildRequestData(ProjectInstance projectInstance, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) { throw new NotImplementedException(); }
public BuildRequestData (string projectFullPath, IDictionary<string, string> globalProperties, string toolsVersion, string[] targetsToBuild, HostServices hostServices, BuildRequestDataFlags flags) : this (new ProjectInstance (projectFullPath, globalProperties, toolsVersion), targetsToBuild, hostServices, flags) { ExplicitlySpecifiedToolsVersion = toolsVersion; }
internal void Build(Task previousTask, Microsoft.Build.Evaluation.Project project, string targets, BuildRequestDataFlags flags, Microsoft.Build.Utilities.Logger logger) { if (project == null) { throw new ArgumentNullException("project"); } if (logger == null) { throw new ArgumentNullException("logger"); } // Make sure that we are using the project collection from the loaded project, otherwise we are getting // weird cache behavior with the msbuild system var projectInstance = new ProjectInstance(project.Xml, project.ProjectCollection.GlobalProperties, null, project.ProjectCollection); BuildTask = previousTask.ContinueWith(completedPreviousTask => { var buildResult = mainBuildManager.Build( new BuildParameters(project.ProjectCollection) { Loggers = new[] { logger } }, new BuildRequestData(projectInstance, targets.Split(';'), null, flags)); return(buildResult); }); }
public static string GetOrCompileProjectAssembly(string fullProjectLocation, ILogger logger, string targets, bool autoCompileProject, string configuration, string platform = "AnyCPU", Dictionary <string, string> extraProperties = null, bool onlyErrors = false, BuildRequestDataFlags flags = BuildRequestDataFlags.None) { if (fullProjectLocation is null) { throw new ArgumentNullException(nameof(fullProjectLocation)); } if (logger is null) { throw new ArgumentNullException(nameof(logger)); } var project = LoadProject(fullProjectLocation, configuration, platform, extraProperties); var assemblyPath = project.GetPropertyValue("TargetPath"); try { if (!string.IsNullOrWhiteSpace(assemblyPath)) { if (autoCompileProject) { var asyncBuild = new CancellableAsyncBuild(project, assemblyPath); asyncBuild.Build(project, targets, flags, new LoggerRedirect(logger, onlyErrors)); asyncBuild.BuildTask.Wait(); } } } finally { project.ProjectCollection.UnloadAllProjects(); project.ProjectCollection.Dispose(); } return(assemblyPath); }
public static string GetOrCompileProjectAssembly(string solutionFullPath, string fullProjectLocation, ILogger logger, string targets, bool autoCompileProject, string configuration, string platform = "AnyCPU", Dictionary <string, string> extraProperties = null, bool onlyErrors = false, BuildRequestDataFlags flags = BuildRequestDataFlags.None) { if (fullProjectLocation == null) { throw new ArgumentNullException("fullProjectLocation"); } if (logger == null) { throw new ArgumentNullException("logger"); } var project = LoadProject(fullProjectLocation, configuration, platform, extraProperties); var assemblyPath = project.GetPropertyValue("TargetPath"); try { if (!string.IsNullOrWhiteSpace(assemblyPath)) { if (autoCompileProject) { // NuGet restore // TODO: We might want to call this less regularly than every build (i.e. project creation, and project.json update?) // Probably not worth bothering since it might be part of MSBuild with VS15 var restoreNugetTask = RestoreNugetPackages(logger, solutionFullPath, project); var asyncBuild = new CancellableAsyncBuild(project, assemblyPath); asyncBuild.Build(restoreNugetTask, project, "Build", flags, new LoggerRedirect(logger, onlyErrors)); var buildResult = asyncBuild.BuildTask.Result; } } } finally { project.ProjectCollection.UnloadAllProjects(); project.ProjectCollection.Dispose(); } return(assemblyPath); }