Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Forms/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Fluent:RibbonWindow x:Class="MSBuildExplorer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
xmlns:basic="clr-namespace:MSBuildExplorer.UserControls"
Title="MSBuild Explorer 3" Height="650" Width="900"
WindowStartupLocation="CenterScreen" Icon="/MSBuildExplorer3;component/Resources/Images/MSBEX.ico"
MinHeight="650" MinWidth="750" Closing="Window_Closing">
xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
xmlns:basic="clr-namespace:MSBuildExplorer.UserControls"

Title="MSBuild Explorer 3" Height="650" Width="900"
WindowStartupLocation="CenterScreen" Icon="/MSBuildExplorer3;component/Resources/Images/MSBEX.ico"
MinHeight="650" MinWidth="750" Closing="Window_Closing">
<DockPanel LastChildFill="True">
<Fluent:Ribbon x:Name="fluentRibbon" DockPanel.Dock="Top" SelectedTabIndex="1">
<Fluent:Ribbon.QuickAccessItems>
Expand All @@ -23,6 +24,10 @@
<Fluent:Button Name="buttonBuildPad" Header="BuildPad" Icon="/MSBuildExplorer3;component/Resources/Images/32/spade.png" LargeIcon="/MSBuildExplorer3;component/Resources/Images/32/spade.png" Click="menuShowBuildPad"/>
<Fluent:Button Name="buttonConsoleBuild" Header="Build" Icon="/MSBuildExplorer3;component/Resources/Images/32/build.png" LargeIcon="/MSBuildExplorer3;component/Resources/Images/32/build.png" Click="menuConsoleBuild"/>
</Fluent:RibbonGroupBox>
<Fluent:RibbonGroupBox Header="Global Properties" Width="200">
<Fluent:ComboBox Name="comboGlobalConfiguration" Header="Configuration" SelectionChanged="comboGlobalConfiguration_SelectionChanged" />
<Fluent:ComboBox Name="comboGlobalPlatform" Header="Platform" SelectionChanged="comboGlobalPlatform_SelectionChanged" Width="190" Margin="0,5,0,0" />
</Fluent:RibbonGroupBox>
</Fluent:RibbonTabItem>
<Fluent:RibbonTabItem Header="RESOURCES">
<Fluent:RibbonGroupBox Header="Resources">
Expand Down
38 changes: 38 additions & 0 deletions Forms/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public MainWindow()
this.Top = userPrefs.WindowTop;
this.Left = userPrefs.WindowLeft;
this.WindowState = userPrefs.WindowState;

this.Explorer.T1.AddHandler(UserControls.TreeExplorer.PopulateEverything, new RoutedEventHandler(this.PopulateEverythingHandler));
}

private enum buildMode
Expand Down Expand Up @@ -142,5 +144,41 @@ private void ClearControls()
this.About.Visibility = Visibility.Hidden;
this.Options.Visibility = Visibility.Hidden;
}

private bool LoadingGlobalProps = false;
private void PopulateEverythingHandler(object sender, RoutedEventArgs e)
{
DataModel.MSBuildFile root = this.Explorer.T1.RootFile;
try
{
LoadingGlobalProps = true;
this.comboGlobalConfiguration.ItemsSource = root.GlobalConfigurations;
this.comboGlobalPlatform.ItemsSource = root.GlobalPlatforms;

Microsoft.Build.Evaluation.ProjectProperty defaultConfig = root.ProjectFile.GetProperty("Configuration");
Microsoft.Build.Evaluation.ProjectProperty defaultPlatform = root.ProjectFile.GetProperty("Platform");

this.comboGlobalConfiguration.SelectedItem = defaultConfig.EvaluatedValue;
this.comboGlobalPlatform.SelectedItem = defaultPlatform.EvaluatedValue;
}
finally
{
LoadingGlobalProps = false;
}
}

private void comboGlobalConfiguration_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (LoadingGlobalProps) return;
String newConfig = e.AddedItems[0] as String;
this.Explorer.Reload("Configuration", newConfig);
}

private void comboGlobalPlatform_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (LoadingGlobalProps) return;
String newPlatform = e.AddedItems[0] as String;
this.Explorer.Reload("Platform", newPlatform);
}
}
}
8 changes: 7 additions & 1 deletion Internal/DataModel/MSBuildFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public MSBuildFile(Project proj)
this.Items = new ObservableCollection<MSBuildItems>();
this.Usings = new ObservableCollection<MSBuildUsing>();
this.Imports = new ObservableCollection<MSBuildImport>();
this.GlobalConfigurations = new ObservableCollection<String>();
this.GlobalPlatforms = new ObservableCollection<String>();
}

public Project ProjectFile { get; set; }
Expand All @@ -35,7 +37,11 @@ public MSBuildFile(Project proj)

public ObservableCollection<MSBuildProperties> Properties { get; set; }

public ObservableCollection<MSBuildUsing> Usings { get; set; }
public ObservableCollection<String> GlobalConfigurations { get; set; }

public ObservableCollection<String> GlobalPlatforms { get; set; }

public ObservableCollection<MSBuildUsing> Usings { get; set; }

public ObservableCollection<MSBuildItems> Items { get; set; }

Expand Down
24 changes: 21 additions & 3 deletions MSBuildHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ namespace MSBuildExplorer
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using MSBuildExplorer.DataModel;
using System;

internal static class MSBuildHelper
internal static class MSBuildHelper
{
internal static MSBuildFile GetFile(FileInfo file)
internal static MSBuildFile GetFile(FileInfo file, String propertyName = null, String propertyValue = null)
{
using (ProjectCollection loadedProjects = new ProjectCollection())
{
Expand All @@ -25,6 +26,11 @@ internal static MSBuildFile GetFile(FileInfo file)

loadedProjects.LoadProject(file.FullName);
currentProject = loadedProjects.GetLoadedProjects(file.FullName).FirstOrDefault();
if (!String.IsNullOrEmpty(propertyName))
{
currentProject.SetGlobalProperty(propertyName, propertyValue);
currentProject.ReevaluateIfNecessary();
}

MSBuildFile m = new MSBuildFile(currentProject);
if (currentProject.Targets != null)
Expand All @@ -47,11 +53,23 @@ internal static MSBuildFile GetFile(FileInfo file)
m.Imports.Add(new MSBuildImport(import));
}

foreach (var property in currentProject.Properties)
foreach (ProjectProperty property in currentProject.Properties)
{
m.Properties.Add(new MSBuildProperties(property));
}

var cp = currentProject.ConditionedProperties;
var configs = cp["Configuration"];
var platforms = cp["Platform"];
foreach (String config in configs)
{
m.GlobalConfigurations.Add(config);
}
foreach (String platform in platforms)
{
m.GlobalPlatforms.Add(platform);
}

if (currentProject.AllEvaluatedItems != null)
{
foreach (var item in currentProject.AllEvaluatedItems)
Expand Down
2 changes: 1 addition & 1 deletion UserControls/Main.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:userControls="clr-namespace:MSBuildExplorer.UserControls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
d:DesignHeight="400" d:DesignWidth="900">
<Grid>
<Grid>
<Grid.RowDefinitions>
Expand Down
7 changes: 6 additions & 1 deletion UserControls/Main.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ public void Reload()
{
this.T1.LoadFile(new FileInfo(this.T1.RootFile.ProjectFile.FullPath), true);
}
public void Reload(String propertyName, String PropertyValue)
{
bool forceReload = true;
this.T1.LoadFile(new FileInfo(this.T1.RootFile.ProjectFile.FullPath), true, propertyName, PropertyValue, forceReload);
}

public void Build()
{
Expand Down Expand Up @@ -181,7 +186,7 @@ public void MenuOpen()
this.ofd.Title = "Open";
this.ofd.Multiselect = true;
this.ofd.RestoreDirectory = true;
this.ofd.Filter = "MSBuild Files|*.msbuild;*.proj;*.properties;*.targets;*.tasks;*.csproj;*.vbproj;*.vcxproj;*.msbef|All files|*.*";
this.ofd.Filter = "MSBuild Files|*.msbuild;*.proj;*.props;*.properties;*.targets;*.tasks;*.csproj;*.vbproj;*.vcxproj;*.msbef|All files|*.*";
this.ofd.FilterIndex = 0;
this.ofd.ShowDialog();
foreach (var s in this.ofd.FileNames)
Expand Down
10 changes: 5 additions & 5 deletions UserControls/TreeExplorer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ public TreeExplorer()
InitializeComponent();
}

public void LoadFile(FileInfo file, bool populate)
public void LoadFile(FileInfo file, bool populate, String propertyName = null, String propertyValue = null, bool forceReload = false)
{
if (this.RootFile != null && this.RootFile.ProjectFile.FullPath == file.FullName)
if (this.RootFile != null && this.RootFile.ProjectFile.FullPath == file.FullName && !forceReload)
{
return;
}

RaiseEvent(new RoutedEventArgs(TreeExplorer.StartExplore, this));
MSBuildFileEqualityComparer eq = new MSBuildFileEqualityComparer();

try
{
this.RootFile = MSBuildHelper.GetFile(file);
this.RootFile = MSBuildHelper.GetFile(file, propertyName, propertyValue);
}
catch (Exception ex)
{
this.TreeExeption = ex;
RaiseEvent(new RoutedEventArgs(TreeExplorer.FailedExplore, this));
return;
}

MSBuildFileEqualityComparer eq = new MSBuildFileEqualityComparer();
if (this.files.Contains(this.RootFile, eq))
{
int i = 0;
Expand Down