public async Task <bool> DeployProject() { await LoadProjectSettings(); var credentials = new Credentials(settings.GetString(OAuthTokenKey)); var client = new GitHubClient(new ProductHeaderValue("Kerbal Space Program for Visual Studio")) { Credentials = credentials }; var name = ""; var versionName = ""; await threadHandler.AsyncPump.RunAsync(async() => { using (var readLock = await projectLockService.ReadLockAsync()) { var msBuildProject = await readLock.GetProjectAsync(await project.GetSuggestedConfiguredProjectAsync()); name = msBuildProject.GetPropertyValue("Name"); versionName = msBuildProject.GetProperty(nameof(VersionNamePattern)).EvaluatedValue; } }); var tag = new NewTag { Message = $"Release {versionName} of {name}", Tag = versionName, Type = TaggedType.Commit, Tagger = new Committer(settings.GetString(UsernameKey), "", DateTimeOffset.UtcNow) }; return(false); }
public async Task <string> GetProjectXmlAsync() { using (var access = await _projectLockService.ReadLockAsync()) { var projectXml = await access.GetProjectXmlAsync(_unconfiguredProject.FullPath).ConfigureAwait(true); return(projectXml.RawXml); } }
public async Task <string> GetProjectXmlAsync(UnconfiguredProject unconfiguredProject) { var configuredProject = await unconfiguredProject.GetSuggestedConfiguredProjectAsync().ConfigureAwait(false); using (var access = await _projectLockService.ReadLockAsync()) { var xmlProject = await access.GetProjectAsync(configuredProject).ConfigureAwait(true); // If we don't save here, then there will be a file-changed popup if the msbuild model differed from the file // on disc before we grabbed it here. xmlProject.Save(); return(xmlProject.Xml.RawXml); } }
public Task <TResult> OpenProjectForReadAsync <TResult>(ConfiguredProject project, Func <Project, TResult> action, CancellationToken cancellationToken = default) { Requires.NotNull(project, nameof(project)); Requires.NotNull(project, nameof(action)); return(_projectLockService.ReadLockAsync(async access => { Project evaluatedProject = await access.GetProjectAsync(project, cancellationToken); // Deliberately not async to reduce the type of // code you can run while holding the lock. return action(evaluatedProject); }, cancellationToken)); }
private async Task <ImmutableArray <string> > GetOrderedTargetFrameworksAsync(UnconfiguredProject project) { Requires.NotNull(project, nameof(project)); using (var access = await _projectLockService.ReadLockAsync()) { var projectRoot = await access.GetProjectXmlAsync(project.FullPath).ConfigureAwait(false); // If the project already defines a specific "TargetFramework" to target, then this is not a cross-targeting project and we don't need a target framework dimension. var targetFrameworkProperty = GetProperty(projectRoot, TargetFrameworkPropertyName); if (!string.IsNullOrEmpty(targetFrameworkProperty)) { return(ImmutableArray <string> .Empty); } // Read the "TargetFrameworks" property from the project file. // TODO: https://github.com/dotnet/roslyn-project-system/issues/547 // We should read the "TargetFrameworks" properties from msbuild project evaluation at unconfigured project level, but there doesn't seem to be a way to do so. var targetFrameworksProperty = GetProperty(projectRoot, ConfigurationGeneral.TargetFrameworksProperty); if (string.IsNullOrEmpty(targetFrameworksProperty)) { return(ImmutableArray <string> .Empty); } return(ParseTargetFrameworks(targetFrameworksProperty)); } }
public async Task LoadPropertiesAsync() { using (var projectReadLock = await mProjectLockService.ReadLockAsync()) { var configuredProject = await mUnconfiguredProject.GetSuggestedConfiguredProjectAsync(); var project = await projectReadLock.GetProjectAsync(configuredProject); await mUnconfiguredProject.ProjectService.Services.ThreadingPolicy.SwitchToUIThread(); foreach (var propertyName in BuildProperties.ProjectIndependentProperties) { var propertyValue = project.GetPropertyValue(propertyName); BuildProperties.SetProperty(propertyName, propertyValue); } } }
private async Task <string> GetPropertyAsync(string propertyName) { return(await _projectLockService.ReadLockAsync(async (projectReadLock) => { var project = await projectReadLock.GetProjectAsync(ConfiguredProject); return project.GetPropertyValue(propertyName); })); }
private async Task <ProjectItem> GetMsBuildItemByProjectItem(IProjectItem projectItem) { using (var access = await _projectLockService.ReadLockAsync()) { var project = await access.GetProjectAsync(_configuredProject); return(project.GetItemsByEvaluatedInclude(projectItem.EvaluatedInclude).FirstOrDefault(pi => StringComparer.OrdinalIgnoreCase.Equals(pi.ItemType, projectItem.ItemType))); } }
private async Task <string> GetPropertyAsync(string propertyName) { using (var projectReadLock = await _projectLockService.ReadLockAsync()) { var project = await projectReadLock.GetProjectAsync(ConfiguredProject); return(project.GetPropertyValue(propertyName)); } }
public override Task <string> OnGetEvaluatedPropertyValueAsync( string evaluatedPropertyValue, IProjectProperties defaultProperties) { return(_projectLockService.ReadLockAsync(async access => { ProjectRootElement projectXml = await access.GetProjectXmlAsync(_unconfiguredProject.FullPath); return await _helper.GetPropertyAsync(projectXml, defaultProperties); })); }
public override async Task <string> OnGetEvaluatedPropertyValueAsync( string evaluatedPropertyValue, IProjectProperties defaultProperties) { using (var access = await _projectLockService.ReadLockAsync()) { var projectXml = await access.GetProjectXmlAsync(_unconfiguredProject.FullPath).ConfigureAwait(true); return(await _helper.GetPropertyAsync(projectXml, defaultProperties).ConfigureAwait(true)); } }
public async Task <string> GetEvaluatedPropertyValue(UnconfiguredProject unconfiguredProject, string propertyName) { var configuredProject = await unconfiguredProject.GetSuggestedConfiguredProjectAsync().ConfigureAwait(false); using (var access = await _projectLockService.ReadLockAsync()) { var evaluatedProject = await access.GetProjectAsync(configuredProject).ConfigureAwait(false); return(evaluatedProject.GetProperty(propertyName)?.EvaluatedValue); } }
public override async Task <string> OnGetEvaluatedPropertyValueAsync( string evaluatedPropertyValue, IProjectProperties defaultProperties) { using (ProjectLockReleaser access = await _projectLockService.ReadLockAsync()) { Microsoft.Build.Construction.ProjectRootElement projectXml = await access.GetProjectXmlAsync(_unconfiguredProject.FullPath); return(await _helper.GetPropertyAsync(projectXml, defaultProperties)); } }
public override Task <string> OnGetEvaluatedPropertyValueAsync( string evaluatedPropertyValue, IProjectProperties defaultProperties) { #pragma warning disable RS0030 // symbol IProjectLockService is banned return(_projectLockService.ReadLockAsync(async access => { ProjectRootElement projectXml = await access.GetProjectXmlAsync(_unconfiguredProject.FullPath); return await _helper.GetPropertyAsync(projectXml, defaultProperties); })); #pragma warning restore RS0030 // symbol IProjectLockService is banned }
private async Task <ProjectItem> RenameProjectItem(IProjectItem projectItem, string newValue) { using (var access = await _projectLockService.ReadLockAsync()) { var project = await access.GetProjectAsync(_configuredProject); var msbuildItem = project .GetItemsByEvaluatedInclude(projectItem.EvaluatedInclude) .FirstOrDefault(pi => pi.ItemType.EqualsIgnoreCase(projectItem.ItemType)); if (projectItem.UnevaluatedInclude.EqualsOrdinal(newValue)) { return(msbuildItem); } newValue = _unconfiguredProject.MakeRooted(newValue); if (!_unconfiguredProject.IsOutsideProjectDirectory(newValue)) { newValue = _unconfiguredProject.MakeRelative(newValue); } return(project.GetItems(projectItem.ItemType) .FirstOrDefault(pi => pi.UnevaluatedInclude.EqualsIgnoreCase(newValue)) ?? msbuildItem); } }
internal async Task LoadFromProject() { await threadHandling.AsyncPump.RunAsync(async() => { using (var readLock = await lockService.ReadLockAsync()) { var msBuildProject = await readLock.GetProjectAsync(await project.GetSuggestedConfiguredProjectAsync()); var selectedTargetNameProperty = msBuildProject.GetProperty("SelectedDeployTarget"); if (selectedTargetNameProperty != null && !string.IsNullOrEmpty(selectedTargetNameProperty.EvaluatedValue)) { await threadHandling.SwitchToUIThread(); SelectedTarget = TargetUIs.Single(ui => ui.Name == selectedTargetNameProperty.EvaluatedValue); } } }); if (SelectedTarget != null) { await SelectedTarget.DeployTarget.LoadProjectSettings(); } }