Reputation: 145
Is there a way to output the Build order to a text file via command line?
To explain: We use multiple branches of source and have large solutions of 100+ projects on each branch. I need to write build scripts to build these solutions from command line. We can then tailor the solutions on the branches to only have project references for the projects that team are working on. This should greatly increase solution load time and ease the frustration of the Developers and me, I hope :)
I'm going to keep looking and maybe look at using C# and the APIs provided with VS. We are using 2012 update 1.
Upvotes: 12
Views: 3395
Reputation: 175
Quick way is to do a "Clean Solution" so that you can see the inverted order in build log.
Upvotes: 8
Reputation: 32561
This is a good candidate for a Visual Studio Plugin project.
In the Connect.cs file, add the following fields:
private BuildEvents _buildEvents;
private Events _events;
private bool buildEventConnected = false;
And add / modify these methods accordingly:
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
_events = _applicationObject.Events;
_buildEvents = _events.BuildEvents;
if (connectMode != ext_ConnectMode.ext_cm_UISetup && !buildEventConnected)
{
_buildEvents.OnBuildDone +=
new _dispBuildEvents_OnBuildDoneEventHandler(BuildEvents_OnBuildDone);
buildEventConnected = true;
}
}
private void BuildEvents_OnBuildDone(vsBuildScope Scope, vsBuildAction Action)
{
const string BUILD_OUTPUT_PANE_GUID = "{1BD8A850-02D1-11D1-BEE7-00A0C913D1F8}";
TextDocument txtOutput = default(TextDocument);
TextSelection txtSelection = default(TextSelection);
Window vsWindow = default(Window);
vsWindow = _applicationObject.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
OutputWindow vsOutputWindow = default(OutputWindow);
OutputWindowPane objBuildOutputWindowPane = default(OutputWindowPane);
vsOutputWindow = (OutputWindow)vsWindow.Object;
foreach (OutputWindowPane objOutputWindowPane in vsOutputWindow.OutputWindowPanes)
{
if (objOutputWindowPane.Guid.ToUpper() == BUILD_OUTPUT_PANE_GUID)
{
objBuildOutputWindowPane = objOutputWindowPane;
break;
}
}
txtOutput = objBuildOutputWindowPane.TextDocument;
txtSelection = txtOutput.Selection;
txtSelection.StartOfDocument(false);
txtSelection.EndOfDocument(true);
objBuildOutputWindowPane.OutputString(System.DateTime.Now.ToString());
txtSelection = txtOutput.Selection;
var solutionDir = System.IO.Path.GetDirectoryName(_applicationObject.Solution.FullName);
System.IO.File.WriteAllText(solutionDir + "\\build_output.log", txtSelection.Text);
}
public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom)
{
if (buildEventConnected)
{
_buildEvents.OnBuildDone -= new _dispBuildEvents_OnBuildDoneEventHandler(BuildEvents_OnBuildDone);
buildEventConnected = false;
}
}
That's it, on every build you'll have the output sent to the build_output.log
file in your solution's folder.
Upvotes: 8