wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
129 stars 36 forks source link

Test discovery+Code Coverage fail on System.ArgumentException when a WIX project is in workspace #6448

Open antibarbie opened 3 years ago

antibarbie commented 3 years ago

First I was unsure if the bug should be reported to WixToolset or Nunit ; bug the stack trace seems to point to WixToolset.

v3.11.3.4516

1.0.0.4

4.7.2 / .Netstandard2.0 / .Netcore2.1

I am trying to run tests with NUnit and NUnit3TestAdapter versions : NUnit Adapter 3.13.0.0 / NUnit 3.12.0

The Test output in Visual Studio show "ArgumentException" stack traces - Code coverage is completely broken, and test discovery also seems to fail somewhat (maybe that's not an issue if it fails when discovering test in a wixproj).

When unloading .wixproj, code coverage functions properly. With the .Wixproj loaded, code coverage is completely broken.

A short repro: Create a .SLN with a nunit test project and a .vixproj project - use code coverage on the nunit project

ps: I really don't know why should MS-Visual should invoke msbuild on the wixproj when launching code coverage, maybe I can help debugging this extension & send a pull request to make the code more resilient.

**// In Code Coverage //**
System.ArgumentException: La valeur n'est pas comprise dans la plage attendue.
   à System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   à WixToolset.VisualStudioExtension.WixBuildMacroCollection.DefineProjectReferenceConfigurations(WixProjectNode project)
   à WixToolset.VisualStudioExtension.WixProjectNode.InvokeMsBuild(String target)
   à Microsoft.VisualStudio.Package.ProjectNode.Build(UInt32 vsopts, ConfigCanonicalName configCanonicalName, IVsOutputWindowPane output, String target)
   à Microsoft.VisualStudio.Package.OutputGroup.Refresh()
   à Microsoft.VisualStudio.Package.OutputGroup.get_KeyOutputObject(IVsOutput2& ppKeyOutput)
   à Microsoft.VisualStudio.Shell.Interop.VSProjectExtensions.GetKeyOutputForIVsOutputGroup2(IVsOutputGroup2 outputGroup2)
   à Microsoft.VisualStudio.Shell.Interop.VSProjectExtensions.GetProjectPutputPath(IVsProjectCfg2 projectConfig, String groupName)
   à Microsoft.VisualStudio.Shell.Interop.VSProjectExtensions.GetKeyOutputForGroup(IVsSolutionBuildManager buildManager, IVsProject project, String groupName)
   à Microsoft.VisualStudio.TestWindow.CodeCoverage.CodeCoverageHost.<>c__DisplayClass3_0.<get_AllProjectOutputs>b__0(IVsProject ph)
   à System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   à System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   à System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   à System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   à Microsoft.VisualStudio.TestWindow.CodeCoverage.CodeCoverageHost.get_AllProjectOutputs()
   à Microsoft.VisualStudio.TestWindow.CodeCoverage.AnalyzeCodeCoverageCommandBase.OnAnalyzeCodeCoverageOperationStateChanged(Object sender, OperationStateChangedEventArgs e)
   à System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   à Microsoft.VisualStudio.TestWindow.Controller.OperationData.<>c__DisplayClass46_0.<OnStateChanged>b__0()
   à Microsoft.VisualStudio.TestWindow.Extensibility.ILoggerExtensions.CallInternalWithLogging(ILogger2 log, Action action, Boolean shouldThrow)
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---

**// In test discovery //**
System.ArgumentException: La valeur n'est pas comprise dans la plage attendue.
   à System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   à WixToolset.VisualStudioExtension.WixBuildMacroCollection.DefineProjectReferenceConfigurations(WixProjectNode project)
   à WixToolset.VisualStudioExtension.WixProjectNode.InvokeMsBuild(String target)
   à Microsoft.VisualStudio.Package.ProjectNode.Build(UInt32 vsopts, ConfigCanonicalName configCanonicalName, IVsOutputWindowPane output, String target)
   à Microsoft.VisualStudio.Package.OutputGroup.Refresh()
   à Microsoft.VisualStudio.Package.OutputGroup.get_KeyOutputObject(IVsOutput2& ppKeyOutput)
   à Microsoft.VisualStudio.TestWindow.ShellServices.ProjectData.<>c__DisplayClass82_0.<GetKeyOutputForIVsOutputGroup2>b__0()
   à Microsoft.VisualStudio.TestWindow.Extensibility.ILoggerExtensions.CallWithCatchThrowCritical[T](ILogger2 log, Func`1 action, T defaultValue)
antibarbie commented 3 years ago

After reviewing the code... The culprit could be a project referenced by the wixproj. Or maybe the code is a bit too sensitive.. (This bug could be related to issue https://github.com/wixtoolset/issues/issues/2261). Any suggestion to seek the guilty package among hundreds of packages?

            if (projectCfg2 != null)
            {
                hr = projectCfg2.get_DisplayName(out configuration);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
            }