Giter Site home page Giter Site logo

kirillosenkov / msbuildstructuredlog Goto Github PK

View Code? Open in Web Editor NEW
1.4K 38.0 188.0 5.84 MB

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.

License: MIT License

C# 99.88% PowerShell 0.07% Shell 0.03% Batchfile 0.02%
msbuild nuget viewer avalonia csharp dotnet wpf

msbuildstructuredlog's Issues

Squirrel Bug

Hi Kirill,

I have the following issue:
image
image

Best,
Maher

How to reference logger when added via NuGet

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.

Portable Version

@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!

Seems to have troubling building solutions that use different versions of MSBuild

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?

detect rebuild problems?

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.

Support searching based on node hierarchy

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.

Infinite Measure/Arrange/Layout/Scroll loop possible with the treeview

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).

Skipped targets are not displayed in the expected order

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:

image

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.

image

Add AppVeyor build

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.

Crashes on invalid input file

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[])

Build Solution fails with System.Xml.XmlException: Unexpected end of file has occurred

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.

Finding StructuredLogViewer installation path

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?

Silverlight 4 SDK is not installed

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]

NuGet packaging bugs

  • You populate the lib\net45 folder but your projects actually target .NET 4.6. This will cause .NET 4.5 projects that install your packages to fail.
  • You populate the lib folder with assemblies that you got from other NuGet packages instead of expressing a dependency on their package. This will cause projects to be unable to depend on these other packages and then add yours without errors.

Error while analyzing build: An item with the same key has already been added.

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 :)

Can't start logged build

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.

Pass log file to open to log viewer as command line argument

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.

Property reassignment messages clutter up the view

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.

Long messages should not be truncated in the lower "details" pane

Long messages are currently truncated with the message "(Ctrl+C to copy full text)". There should be a way to view the full message without having to copy it to an external editor. Probably a good way to do this would be to show the untruncated text word-wrapped in the yellow pane at the bottom.

image

Feature Request: Framework 1.0 - 3.5

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!

Build failure:

@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]

'Build and View Log' from 'Solution Explorer' context menu

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.

Feature request: To be able to change the current culture and MSBuild language

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.

Set logger verbosity independently of console verbosity

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 ?

Feature request: verification mode

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
)

StructuredLogViewer fails to load large log files

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 env variables

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.

Add support for dotnet msbuild

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.