private async Task <BuildResult> BuildProjectAsync(CancellationToken cancellationToken) { using (var readLock = await ProjectLockService.ReadLockAsync(cancellationToken)) { var project = await readLock.GetProjectAsync(ConfiguredProject, cancellationToken); var projectName = project.FullPath; var buildFilter = project.Xml.Properties.Where(a => a.Name == Constants.DominoBuildFilterProp).Select(a => a.Value).FirstOrDefault(); if (buildFilter == null) { // Some BuildXL native projects do not have the output directory because they do not call linker. It means that the other native projects will build them. That's why, just return 'success' for those projects. return(BuildSuccessResult); } // Building native projects does not use the BuildFilter even if it is given. We just use the spec file filtering for those. var specFile = project.Xml.Properties.Where(a => a.Name == Constants.DominoSpecFileProp).Select(a => a.Value).FirstOrDefault(); if (specFile != null) { var result = await BuildManagerHolder.BuildManager.BuildProjectAsync(projectName, SpecUtilities.GenerateSpecFilter(specFile)); return(result ? BuildSuccessResult : BuildFailResult); } return(BuildFailResult); } }
public async Task <Microsoft.Build.Evaluation.Project> GetProjectAsync() { // If we already have access we can just use it to get an instance of the project if (Access == null) { Access = await ProjectLockService.ReadLockAsync(); } return(await Access.Value.GetProjectAsync(ConfiguredProject).ConfigureAwait(false)); }
protected override async Task <ImmutableHashSet <string> > GetCapabilitiesAsync(CancellationToken cancellationToken) { return(await ProjectLockService.ReadLockAsync((releaser) => { using (releaser) { return _capabilities; } }, cancellationToken)); }
public CPSProjectManagerI(UnconfiguredProject unconfiguredProject) { UnconfiguredProject = unconfiguredProject; ProjectLockService = unconfiguredProject.ProjectService.Services.ProjectLockService; ThreadingService = unconfiguredProject.ProjectService.Services.ThreadingPolicy; var activeConfiguredProjectSubscription = unconfiguredProject.Services.ActiveConfiguredProjectSubscription; var projectSource = activeConfiguredProjectSubscription.ProjectSource; ProjectSubscription = projectSource.SourceBlock.LinkTo( new ActionBlock <IProjectVersionedValue <IProjectSnapshot> >(ProjectUpdateAsync)); ThreadingService.ExecuteSynchronously(async() => { using (var projectWriteLock = await ProjectLockService.ReadLockAsync()) { var configuredProject = await UnconfiguredProject.GetSuggestedConfiguredProjectAsync(); MSBuildProject = await projectWriteLock.GetProjectAsync(configuredProject); } }); }
TResult ExecuteLockAction <TResult>(Func <Microsoft.Build.Evaluation.Project, TResult> callback, LockType lockType = LockType.Read, TResult defaultValue = default(TResult)) { var context = ContainingProject as IVsBrowseObjectContext; if (context == null) { context = ContainingProject.Object as IVsBrowseObjectContext; } if (context != null) { return(AsyncManager.Run(async() => { if (lockType == LockType.Read) { using (var access = await ProjectLockService.ReadLockAsync()) { var configuredProject = await context.UnconfiguredProject.GetSuggestedConfiguredProjectAsync(); var project = await access.GetProjectAsync(configuredProject); return callback(project); } } else { using (var access = await ProjectLockService.WriteLockAsync()) { var configuredProject = await context.UnconfiguredProject.GetSuggestedConfiguredProjectAsync(); var project = await access.GetProjectAsync(configuredProject); return callback(project); } } })); } return(defaultValue); }