static MSBuildTask FindErrorTaskForImport(MSBuildTarget target, string import) { string condition = String.Format("!Exists('{0}')", import); return(target.Tasks .FirstOrDefault(task => IsMatchIgnoringCase(task.Condition, condition))); }
void AddMSBuildTargetToListView(MSBuildTarget target) { int row = listStore.AddRow(); listStore.SetValues( row, projectDataField, target.ProjectFileName.FileName, dimensionsDataField, target.Dimensions, elapsedDataField, GetDisplayText(target.Duration), targetsDataField, target.Targets, typeDataField, target.BuildType.ToString(), startDataField, GetDisplayText(target.StartTime), statusDataField, target.Status.GetDisplayText(), msbuildTargetDataField, target); }
public void UpdateProject(MSBuildProject project) { if (importToRemove == null) { return; } MSBuildTarget nugetImportTarget = FindNuGetImportTarget(project); if (nugetImportTarget == null) { return; } MSBuildTask msbuildTask = FindErrorTaskForImport(nugetImportTarget, importToRemove); if (msbuildTask == null) { return; } nugetImportTarget.RemoveTask(msbuildTask); if (nugetImportTarget.Tasks.Count() == 0) { project.Remove(nugetImportTarget); } }
void DeleteMSBuildOutputFiles() { MSBuildTarget target = null; for (int row = 0; row < listStore.RowCount; ++row) { try { target = listStore.GetValue(row, msbuildTargetDataField); if (target.LogFileName.IsNotNull) { File.Delete(target.LogFileName); } if (target.BinLogFileName.IsNotNull) { File.Delete(target.BinLogFileName); } } catch (Exception ex) { LoggingService.LogError( string.Format("Unable to remove msbuild output file {0}", target), ex); } } }
public void TestConstructor_SetsTarget() { const string expectedTarget = "ExpectedTarget"; var objectUnderTest = new MSBuildTarget(expectedTarget); Assert.AreEqual(expectedTarget, objectUnderTest.Target); }
bool MSBuildLogFileExists() { MSBuildTarget target = GetMSBuildTargetForSelectedRow(); return(target != null && target.LogFileName.IsNotNull && File.Exists(target.LogFileName)); }
internal void AddTargetToBuild(object p) { MSBuildTarget sourceTask = (MSBuildTarget)p; if (!this.TargetsToBuild.Contains(sourceTask)) { this.TargetsToBuild.Add(sourceTask); } }
public void AddMSBuildTarget(MSBuildTarget target) { msbuildTargets.Add(target); if (IsAllowedByFilter(target)) { AddMSBuildTargetToListView(target); } }
/// <summary> /// Get hover content for an <see cref="MSBuildTarget"/>. /// </summary> /// <param name="target"> /// The <see cref="MSBuildTarget"/>. /// </param> /// <returns> /// The content, or <c>null</c> if no content is provided. /// </returns> public MarkedStringContainer Target(MSBuildTarget target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } return($"Target: `{target.Name}`"); }
bool IsAllowedByFilter(MSBuildTarget target) { if (buildType != BuildType.All && buildType != target.BuildType) { return(false); } return(IsAllowedBySearchFilter(target)); }
void OpenLogFileForRow(int row, bool binLog = false) { MSBuildTarget target = GetMSBuildTargetForRow(row); FilePath fileNameToOpen = binLog ? target.BinLogFileName : target.LogFileName; if (fileNameToOpen.IsNotNull && File.Exists(fileNameToOpen)) { IdeApp.Workbench.OpenDocument(fileNameToOpen, (Project)null) .Ignore(); } }
internal void PopulateTargetDetails(MSBuildTarget m) { this.targetDetails = new ObservableCollection <MSBuildTargetDetails>(); this.targetDetails.Add(new MSBuildTargetDetails("Name", m.Name)); this.targetDetails.Add(new MSBuildTargetDetails("Location", m.Location)); this.targetDetails.Add(new MSBuildTargetDetails("Condition", m.TargetCondition)); this.targetDetails.Add(new MSBuildTargetDetails("DependsOnTargets", m.DependsOnTargets)); this.targetDetails.Add(new MSBuildTargetDetails("Inputs", m.Inputs)); this.targetDetails.Add(new MSBuildTargetDetails("Outputs", m.Outputs)); this.targetDetails.Add(new MSBuildTargetDetails("BeforeTargets", m.BeforeTargets)); this.targetDetails.Add(new MSBuildTargetDetails("AfterTargets", m.AfterTargets)); this.dataGridTargetDetails.ItemsSource = this.targetDetails; }
private void treeviewTargets_Drop(object sender, System.Windows.DragEventArgs e) { if (e.Data.GetDataPresent(typeof(MSBuildTarget))) { MSBuildTarget sourceTask = (MSBuildTarget)e.Data.GetData(typeof(MSBuildTarget)); if (!this.TargetsToBuild.Contains(sourceTask)) { this.TargetsToBuild.Add(sourceTask); } this.windowTitle = "MSBuild Explorer Custom Target Run"; } }
bool MSBuildBinLogFileExists() { MSBuildTarget target = GetMSBuildTargetForSelectedRow(); if (target == null) { return(false); } target.CopyBinLogFile(); return(target.BinLogFileName.IsNotNull && File.Exists(target.BinLogFileName)); }
private void tvMain_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { MSBuildFile f = this.tvMain.SelectedItem as MSBuildFile; if (f != null) { foreach (MSBuildFile mf in this.files) { if (f == mf) { this.RootFile = mf; break; } } RaiseEvent(new RoutedEventArgs(TreeExplorer.PopulateEverything, this)); return; } MSBuildTarget t = this.tvMain.SelectedItem as MSBuildTarget; if (t != null) { bool raise = false; this.ActiveMSBuildTarget = t; foreach (MSBuildFile mf in this.files) { if (t.Parent == mf && t.Parent != this.RootFile) { this.RootFile = mf; raise = true; break; } } if (raise) { RaiseEvent(new RoutedEventArgs(TreeExplorer.PopulateEverything, this)); } RaiseEvent(new RoutedEventArgs(TreeExplorer.TargetClick, this)); } if (this.files.Count == 0) { this.RootFile = null; RaiseEvent(new RoutedEventArgs(TreeExplorer.PopulateEverything, this)); } }
private void MenuItem_Click(object sender, RoutedEventArgs e) { MSBuildTarget f = this.treeviewTargets.SelectedItem as MSBuildTarget; if (f == null) { return; } foreach (MSBuildTarget mf in this.TargetsToBuild.Where(mf => f == mf)) { this.TargetsToBuild.Remove(mf); break; } }
private void ImageMoveUp_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { MSBuildTarget selectedfile = this.treeviewTargets.SelectedItem as MSBuildTarget; if (selectedfile != null) { int index = this.TargetsToBuild.IndexOf(selectedfile); if (index > 0) { this.TargetsToBuild.Remove(selectedfile); this.TargetsToBuild.Insert(index - 1, selectedfile); selectedfile.IsSelected = true; this.treeviewTargets.Items.Refresh(); } } }
bool IsAllowedBySearchFilter(MSBuildTarget target) { if (string.IsNullOrEmpty(searchFilter)) { return(true); } return (IsSearchFilterMatch(target.BuildType.ToString()) || IsSearchFilterMatch(target.Dimensions) || IsSearchFilterMatch(target.ProjectFileName.FileName) || IsSearchFilterMatch(target.ProjectName) || IsSearchFilterMatch(target.Status.GetDisplayText()) || IsSearchFilterMatch(target.Targets) || IsSearchFilterMatch(GetDisplayText(target.Duration)) || IsSearchFilterMatch(GetDisplayText(target.StartTime))); }
private void tvMain_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DependencyObject src = (DependencyObject)e.OriginalSource; while (!(src is Control)) { src = VisualTreeHelper.GetParent(src); } if (src.GetType().Name == "TreeViewItem") { MSBuildTarget f = this.tvMain.SelectedItem as MSBuildTarget; if (f != null) { this.ActiveMSBuildTarget = f; RaiseEvent(new RoutedEventArgs(TreeExplorer.TargetDoubleClick, this)); } } }
public void UpdateMSBuildTarget(MSBuildTarget target) { for (int row = listStore.RowCount - 1; row >= 0; --row) { MSBuildTarget currentTarget = listStore.GetValue(row, msbuildTargetDataField); if (target == currentTarget) { listStore.SetValues( row, elapsedDataField, GetDisplayText(target.Duration), statusDataField, target.Status.GetDisplayText()); return; } } }
private void menuRemoveOthers_Click(object sender, RoutedEventArgs e) { MSBuildTarget f = this.treeviewTargets.SelectedItem as MSBuildTarget; if (f == null) { return; } ObservableCollection <MSBuildTarget> targetsToBuildTemp = new ObservableCollection <MSBuildTarget>(); foreach (MSBuildTarget mf in this.TargetsToBuild.Where(mf => f != mf)) { targetsToBuildTemp.Add(mf); } foreach (MSBuildTarget mf in targetsToBuildTemp) { this.TargetsToBuild.Remove(mf); } }
public void SaveProject_ProjectHasOneImportInNuGetImportTargetHasDifferentCaseAndItIsBeingRemoved_NuGetImportTargetIsRemoved() { CreateMSBuildProject( "<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n" + " <Target Name=\"ENSUREnugetpackagebuildIMPORTS\" BeforeTargets=\"PrepareForBuild\">\r\n" + " <PropertyGroup>\r\n" + " <ErrorText>Error.</ErrorText>\r\n" + " </PropertyGroup>\r\n" + " <Error Condition=\"!Exists('packages\\Xamarin.Forms.1.2.3.6257\\build\\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\\Xamarin.Forms.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', 'packages\\Xamarin.Forms.1.2.3.6257\\build\\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\\Xamarin.Forms.targets'))\" />\r\n" + " </Target>\r\n" + "</Project>"); int targetCountBeforeSave = msbuildProject.Targets.Count(); string import = @"packages\Xamarin.Forms.1.2.3.6257\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets"; CreateUpdaterWithImportToRemove(import); SaveProject(); MSBuildTarget target = msbuildProject.Targets.FirstOrDefault(); Assert.AreEqual(1, targetCountBeforeSave); Assert.AreEqual(0, msbuildProject.Targets.Count()); }
public void SaveProject_ProjectHasTwoImportsInNuGetImportAndOneBeingRemoved_ImportRemovedFromNuGetImport() { CreateMSBuildProject( "<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n" + " <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n" + " <PropertyGroup>\r\n" + " <ErrorText>Error.</ErrorText>\r\n" + " </PropertyGroup>\r\n" + " <Error Condition=\"!Exists('packages\\Xamarin.Forms.1.2.3.6257\\build\\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\\Xamarin.Forms.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', 'packages\\Xamarin.Forms.1.2.3.6257\\build\\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\\Xamarin.Forms.targets'))\" />\r\n" + " <Error Condition=\"!Exists('packages\\Other.1.1.0\\build\\Other.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', 'packages\\Other.1.1.0\\build\\Other.targets'))\" />\r\n" + " </Target>\r\n" + "</Project>"); int taskCountBeforeSave = msbuildProject.Targets.FirstOrDefault().Tasks.Count(); SaveProject(); MSBuildTarget target = msbuildProject.Targets.FirstOrDefault(); Assert.AreEqual(2, taskCountBeforeSave); Assert.AreEqual(1, target.Tasks.Count()); Assert.IsTrue(target.Tasks.Any(t => t.Condition == @"!Exists('packages\Other.1.1.0\build\Other.targets')")); Assert.IsFalse(target.Tasks.Any(t => t.Condition == @"!Exists('packages\Xamarin.Forms.1.2.3.6257\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets')")); }
/// <summary> /// Get hover content for an <see cref="MSBuildTarget"/>. /// </summary> /// <param name="target"> /// The <see cref="MSBuildTarget"/>. /// </param> /// <returns> /// The content, or <c>null</c> if no content is provided. /// </returns> public MarkedStringContainer Target(MSBuildTarget target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } List <MarkedString> content = new List <MarkedString> { $"Target: `{target.Name}`" }; string helpLink = MSBuildSchemaHelp.HelpLinkForElement(target.Element.Name); if (!String.IsNullOrWhiteSpace(helpLink)) { content.Add( $"[Help]({helpLink})" ); } return(new MarkedStringContainer(content)); }
public void TargetDoubleClickHandler(object sender, RoutedEventArgs e) { MSBuildTarget m = this.T1.ActiveMSBuildTarget; this.D1.AddTargetToBuild(m); }
public void TestToString_ReturnsMSBuildCliArgument() { var objectUnderTest = new MSBuildTarget("ExpectedTarget"); Assert.AreEqual("/t:ExpectedTarget", objectUnderTest.ToString()); }
public void TargetClickHandler(object sender, RoutedEventArgs e) { MSBuildTarget m = this.T1.ActiveMSBuildTarget; this.D1.PopulateTargetDetails(m); }
internal void Build(Project proj, bool consoleBuild, string targetToBuild, string title = "") { if (!string.IsNullOrEmpty(title)) { this.windowTitle = title; } if (string.IsNullOrEmpty(targetToBuild)) { this.windowTitle = new FileInfo(proj.FullPath).Name; } if (consoleBuild) { string targets = targetToBuild; if (!string.IsNullOrEmpty(targets)) { targets = "/t:" + targets; } else if (this.treeviewTargets.Items.Count > 0) { targets = (from object target in this.treeviewTargets.Items select target as MSBuildTarget).Aggregate(targets, (current, t) => current + (t.Name + ";")); targets = "/t:" + targets.Remove(targets.LastIndexOf(';'), 1); } string appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); string args = string.Format(CultureInfo.CurrentCulture, "\"{0}\" {1} {2}", proj.FullPath, targets, this.TextBoxParameters.Text); using (FileStream fileStream = File.Open(appStartPath + @"\wrap.bat", FileMode.Create)) { using (StreamWriter streamWriter = new StreamWriter(fileStream)) { streamWriter.WriteLine(@"TITLE " + this.windowTitle); streamWriter.WriteLine(@"ECHO Off"); streamWriter.Write(this.TextBoxPreExecute.Text); streamWriter.WriteLine(); streamWriter.WriteLine(@"msbuild.exe " + args); if (Settings.Default.PauseConsoleAfterExecution) { streamWriter.WriteLine(@"pause"); } } } // configure the process we need to run Process buildwrapper = new Process { StartInfo = { FileName = appStartPath + @"\wrap.bat", UseShellExecute = false, Arguments = args } }; // start the process buildwrapper.Start(); } else { try { MSBuildExplorerLogger logger = new MSBuildExplorerLogger { Verbosity = LoggerVerbosity.Diagnostic }; logger.OnMessage += this.LogBuildMessage; if (this.treeviewTargets.Items.Count > 0) { string[] targets = new string[this.treeviewTargets.Items.Count]; int i = 0; foreach (var target in this.treeviewTargets.Items) { MSBuildTarget t = target as MSBuildTarget; if (t != null) { targets[i] = t.Name; } i++; } System.Collections.Generic.IEnumerable <ILogger> tt = new ILogger[] { logger }; proj.Build(targets, tt); } else { proj.Build(logger); } // this.TextBoxOutput.Document = this.flowDoc; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }