kirillosenkov / msbuildstructuredlog Goto Github PK
View Code? Open in Web Editor NEWA logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
License: MIT License
A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
License: MIT License
Display some sort of perf summary
I installed the version 1.0.123 and found it crashes when I click "Open Log File". The file LoggerExceptions.txt
is attached. The OS is windows 10 Home, with .NET 4.6.2 installed.
It would be nice to have a workspace folder view listing all the projects/solutions that I can build from.
Trying to get this working in our build system as it looks very useful for problem diagnosis.
We use a CI/CD build server to call MS Build. Since the NuGet package contains the assembly I have not installed the DLL onto the build server, I have added the NuGet package to the VS solution and would to reference it from the project bin location or I'd hope MSBuild would reference it itself.
The MS Build cmd line we use specifies the file path to the solution file but it does not know the path to the project file where the DLL is. Since the cmd line is shared across multiple builds I cannot hard code a specific path to a participial project.
Is there a way to get MS Build to resolve the reference to the logger from the project file path without having to hard code the path? If not then I do not understand why having this a a nuget package makes sense.
The full cmdline to MS Build I am using is this:
MSBuild.exe "C:\mypath\mysolution.Api.sln" /nologo /t:Rebuild /p:VisualStudioVersion=12.0 /p:Configuration="Debug" /p:SkipInvalidConfigurations=true /logger:StructuredLogger,StructuredLogger.dll;buildlog1.xml
Any help appreciated.
@KirillOsenkov any plans to make a portable version of this toolset? Looks like the current implementation expects to be run with desktop msbuild. I'd be particularly keen to get access to a portable logger. It'd be great to view the logs x-plat, but shuttling them to a Windows machine for analysis would be a great first step!
It would be very useful to have timing information in the main tree view, so we can see things like which project took the longest, and how much time was spent building dependent projects
Built Roslyn.sln and then build ProjectSystem.sln from the UI, and get:
C:\Users\davkean\.nuget\packages\Microsoft.VisualStudio.ProjectSystem.SDK.Tools\15.0.183-pre\build\Microsoft.VisualStudio.ProjectSystem.Sdk.Tools.targets(53,5): error MSB4127: The "XamlRuleToCode" task could not be instantiated from the assembly "C:\Users\davkean\.nuget\packages\Microsoft.VisualStudio.ProjectSystem.SDK.Tools\15.0.183-pre\build\Microsoft.VisualStudio.ProjectSystem.Sdk.Tasks.dll". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.NonShippingTasks.XamlRuleToCode' to type 'Microsoft.Build.Framework.ITask'. [C:\roslyn-project-system\src\Microsoft.VisualStudio.ProjectSystem.Managed\Microsoft.VisualStudio.ProjectSystem.Managed.csproj]
I'm guessing first MSBuild to load wins?
Is it possible to highlight issues leading to more rebuilds than necessary?
A prime example is a C++ project with a header file that does not exist on disc.
But in a mixed (C#, managed C++) solution there are other causes we couldn't figure out yet.
It would be useful to be able to search for items based on their parent or ancestor nodes. For example, it would be useful to be able to filter results to those that occurred when running a particular target. One possible syntax for this would be something like $target _HandlePackageFileConflicts \ System.IO.dll
to search for System.IO.dll under the _HandlePackageFileConflicts
target. Since targets that a target depends on are nested under the target, it would also be helpful to be able to specify whether to search only under the specified target or under any other targets that are shown nested within it.
Since the big treeview is virtualized and variable height (due to the yellow breadcrumb panel at the bottom), it is a recipe for disaster - we can fall into an infinite layout loop in WPF (which is a known problem: https://connect.microsoft.com/VisualStudio/feedback/details/969547/infinite-measure-and-arrange-loop-with-virtualizingstackpanel)
Look into making sure that the treeview height doesn't dance when the selection changes (somehow calm down the layout storm caused by the breadcrumb panel vertical resize).
Build the following project with the /bl
option and open the log in the structured log viewer:
<Project DefaultTargets="Build">
<Target Name="Build" DependsOnTargets="SkippedTarget">
<Message Text="Build" Importance="high" />
</Target>
<Target Name="SkippedTarget" Condition="'true' == 'false'">
<Message Text="SkippedTarget" Importance="high" />
</Target>
<Target Name="MessageTarget" BeforeTargets="SkippedTarget">
<Message Text="MessageTarget" Importance="high" />
</Target>
</Project>
EXPECTED: The MessageTarget
target is nested somewhere under the Build
target, before the Message task from the Build
target, indicating it ran first. Something like the following, except with SkippedTarget
grayed out:
ACTUAL: The MessageTarget
is displayed nested under SkippedTarget
, which is after the Build
target, giving the impression that the MessageTarget
ran after Build instead of before it.
To help ensure this project continues to build (with package restore working, etc.) on a clean machine, we should set up an appveyor build. It's really easy.
I'm happy to set this up this weekend and send another PR.
Application: StructuredLogViewer.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.InvalidDataException
at System.IO.Compression.GZipDecoder.ReadHeader(System.IO.Compression.InputBuffer)
at System.IO.Compression.Inflater.Decode()
at System.IO.Compression.Inflater.Inflate(Byte[], Int32, Int32)
at System.IO.Compression.DeflateStream.Read(Byte[], Int32, Int32)
at System.IO.Stream.ReadByte()
at System.IO.BinaryReader.ReadByte()
at System.IO.BinaryReader.Read7BitEncodedInt()
at Microsoft.Build.Logging.StructuredLogger.TreeBinaryReader..ctor(System.String)
at Microsoft.Build.Logging.StructuredLogger.BinaryLogReader..ctor(System.String)
at Microsoft.Build.Logging.StructuredLogger.BinaryLogReader.Read(System.String)
at System.Threading.Tasks.Task`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
at StructuredLogViewer.MainWindow+<OpenLogFile>d__13.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at StructuredLogViewer.Entrypoint.Main(System.String[])
Installed MSBuildStructuredLog
Created a new blank console application in VS2015 Update 2
Tried File|Build Solution on this new solution
I get this error.
Error when opening file: C:\Users\rmd\AppData\Local\Temp\MSBuildStructuredLog-21136.xml
System.Xml.XmlException: Unexpected end of file has occurred. The following elements are not closed: Property, Environment, Build. Line 23, position 27.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ThrowUnclosedElements()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at Microsoft.Build.Logging.StructuredLogger.XmlLogReader.Read(String filePath) in C:\MSBuildStructuredLog\src\StructuredLogger\Serialization\XmlLogReader.cs:line 40
Build failed.
Tried three other existing projects, same results
Tried running as administrator, same results
I looked in the temp folder, but the referenced .xml file does not exist.
I'm setting up a few scripts for my team to use StructuredLogViewer and I have added one additional parameter to our build function to use the StructuredLogger.
After the build is complete, I want to launch the log viewer with the log, but I don't know how to find the install location. Is there an easy way for me to do this? I don't want to manually check-in the binaries if possible to make sure that auto updates work properly. Should I just be searching the AppData folder for the most recent version? Is there a way to run the installer and find the install path?
I'm using Silverlight 5 and when I use MSBuild Structured Log Viewer I find this issue:
C:\Program Files (x86)\MSBuild\Microsoft\Silverlight\v5.0\Microsoft.Silverlight.Common.targets(104, 9) : Silverlight 4 SDK is not installed. [XXXX.csproj]
Open the attached log, which contains a failed build. I need to diagnose why, but all the UI shows is the error, and none of the actual executions :(
I'm seeing this error in one particular project build:
---------------------------
---------------------------
Error while analyzing build. Very sorry about that. Please Ctrl+C to copy this text and file an issue on https://github.com/KirillOsenkov/MSBuildStructuredLog
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Microsoft.Build.Logging.StructuredLogger.CopyLocalAnalyzer.AnalyzeResolveAssemblyReference(Task rar)
at Microsoft.Build.Logging.StructuredLogger.BuildAnalyzer.AnalyzeTask(Task task)
at Microsoft.Build.Logging.StructuredLogger.TreeNode.VisitAllChildren[T](Action`1 processor, CancellationToken cancellationToken) in C:\MSBuildStructuredLog\src\StructuredLogger\ObjectModel\TreeNode.cs:line 408
at Microsoft.Build.Logging.StructuredLogger.TreeNode.VisitAllChildren[T](Action`1 processor, CancellationToken cancellationToken) in C:\MSBuildStructuredLog\src\StructuredLogger\ObjectModel\TreeNode.cs:line 420
at Microsoft.Build.Logging.StructuredLogger.TreeNode.VisitAllChildren[T](Action`1 processor, CancellationToken cancellationToken) in C:\MSBuildStructuredLog\src\StructuredLogger\ObjectModel\TreeNode.cs:line 420
at Microsoft.Build.Logging.StructuredLogger.TreeNode.VisitAllChildren[T](Action`1 processor, CancellationToken cancellationToken) in C:\MSBuildStructuredLog\src\StructuredLogger\ObjectModel\TreeNode.cs:line 420
at Microsoft.Build.Logging.StructuredLogger.TreeNode.VisitAllChildren[T](Action`1 processor, CancellationToken cancellationToken) in C:\MSBuildStructuredLog\src\StructuredLogger\ObjectModel\TreeNode.cs:line 420
at Microsoft.Build.Logging.StructuredLogger.TreeNode.VisitAllChildren[T](Action`1 processor, CancellationToken cancellationToken) in C:\MSBuildStructuredLog\src\StructuredLogger\ObjectModel\TreeNode.cs:line 420
at Microsoft.Build.Logging.StructuredLogger.TreeNode.VisitAllChildren[T](Action`1 processor, CancellationToken cancellationToken) in C:\MSBuildStructuredLog\src\StructuredLogger\ObjectModel\TreeNode.cs:line 420
at Microsoft.Build.Logging.StructuredLogger.BuildAnalyzer.Analyze()
at Microsoft.Build.Logging.StructuredLogger.BuildAnalyzer.AnalyzeBuild(Build build)
---------------------------
OK
---------------------------
Just following the instruction message and reporting :)
Use the comments to easily upload images for the wiki pages.
When following the example in the readme, except for using the path to the DLL that the installer actually used, it fails with this error:
msbuild /logger:StructuredLogger,C:\Users\andarno\AppData\Local\MSBuildStructuredLogViewer\app-1.0.0\StructuredLogger.dll,buildlog1.xml
MSBUILD : error MSB1021: Cannot create an instance of the logger. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Switch: StructuredLogger,C:\Users\andarno\AppData\Local\MSBuildStructuredLogViewer\app-1.0.0\StructuredLogger.dll,buildlog1.xml
Any ideas? The path to the .dll is valid.
It looks like this command passed in by Squirrel is interpreted as a file and causes the error.
I have a set of scripts to build using the structured logger and I'd like to launch the log viewer and load the log automatically.
Accepting just a file path should be enough. In order to properly support launching the most recent version via Squirrel's update.exe, we'll need to investigate whether or not command line arguments can be pass through to the called app.
Build a simple project with the /bl
option and open its binary log in the structured log viewer. You will mostly see a bunch of "Property Reassignment" messages. For more complex projects (for example, building the .NET CLI repo), there will be an overwhelming amount of these messages, making it hard to browse through the log.
Ideally these messages would be nested under the Properties node of the project where the reassignment occurred. If that's not currently possible, it would at least help to put them all under a single top-level node.
I tried this out today to build older version of .Net framework. This seems like a great tool to help with that. Could we select the version of the framework to target and then build?
Nice Work thanks!
@AArnott off the top of your head, do you know what's wrong here?
git clean, nuget restore, msbuild, I get this;
CreatePackage:
C:\Users\Kirill\.nuget\packages\NuProj\0.10.48-beta-gea4a31bbc5\tools\NuGet.e
xe pack obj\Debug\MSBuildStructuredLogViewer.nuspec -OutputDirectory obj\Debu
g\ -NoPackageAnalysis -NoDefaultExcludes
C:\Users\Kirill\.nuget\packages\NuProj\0.10.48-beta-gea4a31bbc5\tools\NuProj.ta
rgets(525,5): error : The replacement token 'GitCommitIdShort' has no value. [C
:\MSBuildStructuredLog\src\MSBuildStructuredLogViewer\MSBuildStructuredLogViewe
r.nuproj]
It would be great if I could right click on a solution or project inside the 'Solution Explorer' and 'Build and View Log'. MSBuildStructuredLog could be distributed as a Visual Studio package and always be at my fingertips. ๐
Just launching the application form Visual Studio would be handy, it needn't be anything fancy.
Workaround: $copytask
It would be great to be able to change the current culture before excuting MSBuild or to have the ability to change the MSBuild language.
At least it could be set as default to en-US as an option. My machine is in German, my VS is in English but builds run by this tool do get the default German messages on MSBuild log. it is a pain to search using the localized messages on google.
When I use this, I usually want the log file to contain diagnostic level output, but I don't want the console to display diagnostic level output. Would it be possible to set StructuredLogger to verbosity=diag while keeping console output at verbosity=minimal ?
I'm using MSBuildStructuredLog to weed out a number of errors in the Roslyn build. In particular a series of double write bugs.
Once I'm done I want to lock in these wins and ensure double writes don't come back again in the future. I can do this today by running the structured logger in XML mode and dig through the resulting file for errors. Very doable but requires writing a powershell script or building a small tool for the XML processing.
My request is to have structured logger operate in a verification mode. Essentially allow an extra parameter for an error log file. This log file will only be created if there is an error detected during build. That would allow for easy integration into build scripts:
msbuild/logger:StructuredLogger,StructuredLogger.dll;build.xml;error.xml
if EXIST error.xml (
REM the build ... it's broken
)
I have a build which produces 1.5GB log file with StructuredLog logger. When trying to load it to the viewer, I get OutOfMemoryException:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Text.StringBuilder.ToString() at System.Xml.XmlTextReaderImpl.FinishPartialValue() at System.Xml.XmlTextReaderImpl.get_Value() at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r) at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o) at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options) at Microsoft.Build.Logging.StructuredLogger.XmlLogReader.ReadFromXml(String xmlFilePath, Action1 statusUpdate) in C:\MSBuildStructuredLog\src\StructuredLogger\Serialization\XmlLogReader.cs:line 22
This can be easily fixed by unchecking 'Prefer 32bit' option in StructuredLogViewer project build settings, to allow the 64bit JIT for AnyCPU configuration.
MSBuild has an assert, investigate that and log a bug if necessary
Another env variable for your wiki is MSBUILDDISABLENODEREUSE=1 to dispose MSBuild instances after use.
In particular prevents zombie situations with multiple sets of MSBuild processes running.
The dotnet CLI tools enable us to call msbuild via the dotnet msbuild ...
command. Currently it's not possible to attach the structured logger to such a msbuild run, it fails with the following error:
dotnet msbuild Some.sln /v:diag /nologo /logger:StructuredLogger,"C:\Users\SomeUser\AppData\Local\MSBuildStructuredLogViewer\app-1.0.130\StructuredLogger.dll";"C:\Users\SomeUser\Desktop\structuredlog.buildlog"
MSBUILD : error MSB1021: Cannot create an instance of the logger. Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.