madskristensen/BundlerMinifier

VSTS Build Issue - .Net SDK 2.1-rc1

Opened this issue ยท 13 comments

twurm commented

Installed product versions

  • Visual Studio: 2017 Enterprise (15.7.2)
  • This extension: 2.8.391
  • VSTS Agent Version: 2.133.3
  • .Net Core SDK Version: 2.1 RC1

Description

Builds run through VSTS private agent using:

dotnet publish -c Release ProjectXYZ.csproj fail with the following exception. However running the same command on the build agent outside of a VSTS build works correctly. Removing the BundlerMinifier nupkg allows the build to complete as expected though VSTS.

2018-05-22T18:46:44.6543788Z Bundler: Begin processing bundleconfig.json
2018-05-22T18:46:44.7128680Z MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
2018-05-22T18:46:44.7334336Z Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: ContextID 33 should have been in the ID-to-project file mapping but wasn't!
2018-05-22T18:46:44.7334729Z at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Object[] args)
2018-05-22T18:46:44.7347754Z at Microsoft.Build.BackEnd.Logging.LoggingService.GetAndVerifyProjectFileFromContext(BuildEventContext context)
2018-05-22T18:46:44.7348045Z at Microsoft.Build.BackEnd.Logging.LoggingService.LogBuildEvent(BuildEventArgs buildEvent)
2018-05-22T18:46:44.7350081Z at Microsoft.Build.BackEnd.TaskHost.LogErrorEvent(BuildErrorEventArgs e)
2018-05-22T18:46:44.7351916Z at Microsoft.Build.Utilities.TaskLoggingHelper.LogError(String subcategory, String errorCode, String helpKeyword, String file, Int32 lineNumber, Int32 columnNumber, Int32 endLineNumber, Int32 endColumnNumber, String message, Object[] messageArgs)
2018-05-22T18:46:44.7355463Z at BundlerMinifier.BundlerBuildTask.BundleMinifier_ErrorMinifyingFile(Object sender, MinifyFileEventArgs e)
2018-05-22T18:46:44.7355742Z at BundlerMinifier.BundleMinifier.MinifyBundle(Bundle bundle)
2018-05-22T18:46:44.7356938Z at BundlerMinifier.BundleFileProcessor.ProcessBundle(String baseFolder, Bundle bundle)
2018-05-22T18:46:44.7357413Z at BundlerMinifier.BundleFileProcessor.Process(String fileName, IEnumerable1 bundles) 2018-05-22T18:46:44.7357929Z at BundlerMinifier.BundlerBuildTask.Execute() 2018-05-22T18:46:44.7358367Z at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 2018-05-22T18:46:44.7359019Z at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) 2018-05-22T18:46:44.7359883Z at Microsoft.Build.BackEnd.TaskBuilder.InitializeAndExecuteTask(TaskLoggingContext taskLoggingContext, ItemBucket bucket, IDictionary2 taskIdentityParameters, TaskHost taskHost, TaskExecutionMode howToExecuteTask)
2018-05-22T18:46:44.7360551Z at Microsoft.Build.BackEnd.TaskBuilder.ExecuteBucket(TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Dictionary2 lookupHash) 2018-05-22T18:46:44.7361083Z at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(TaskExecutionMode mode, Lookup lookup) 2018-05-22T18:46:44.7361759Z at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(TargetLoggingContext loggingContext, BuildRequestEntry requestEntry, ITargetBuilderCallback targetBuilderCallback, ProjectTargetInstanceChild taskInstance, TaskExecutionMode mode, Lookup inferLookup, Lookup executeLookup, CancellationToken cancellationToken) 2018-05-22T18:46:44.7362574Z at Microsoft.Build.BackEnd.TargetEntry.ProcessBucket(ITaskBuilder taskBuilder, TargetLoggingContext targetLoggingContext, TaskExecutionMode mode, Lookup lookupForInference, Lookup lookupForExecution) 2018-05-22T18:46:44.7363516Z at Microsoft.Build.BackEnd.TargetEntry.ExecuteTarget(ITaskBuilder taskBuilder, BuildRequestEntry requestEntry, ProjectLoggingContext projectLoggingContext, CancellationToken cancellationToken) 2018-05-22T18:46:44.7364122Z at Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(ITaskBuilder taskBuilder) 2018-05-22T18:46:44.7364696Z at Microsoft.Build.BackEnd.TargetBuilder.BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, String[] targetNames, Lookup baseLookup, CancellationToken cancellationToken) 2018-05-22T18:46:44.7365310Z at Microsoft.Build.BackEnd.RequestBuilder.BuildProject() 2018-05-22T18:46:44.7365740Z at Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport() 2018-05-22T18:46:44.7366199Z at Microsoft.Build.BackEnd.RequestBuilder.RequestThreadProc(Boolean setThreadParameters) 2018-05-22T18:46:44.7366515Z 2018-05-22T18:46:44.7464722Z MSBUILD : error MSB1025: An internal failure occurred while running MSBuild. 2018-05-22T18:46:44.7465115Z Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: ContextID 33 should have been in the ID-to-project file mapping but wasn't! 2018-05-22T18:46:44.7465570Z at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary2 globalProperties, Dictionary2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean detailedSummary, ISet1 warningsAsErrors, ISet1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler) 2018-05-22T18:46:44.7467331Z at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine) 2018-05-22T18:46:44.7469547Z 2018-05-22T18:46:44.7482143Z Unhandled Exception: Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: ContextID 33 should have been in the ID-to-project file mapping but wasn't! 2018-05-22T18:46:44.7483048Z at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary2 globalProperties, Dictionary2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean detailedSummary, ISet1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler)
2018-05-22T18:46:44.7483789Z at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
2018-05-22T18:46:44.7484137Z at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)

Hi,
we too are facing this issue, and it is holding us from deploying a successful build, we have two cs projects which make use of BundleMinifier, however the first project built is working fine, and the next project is failing, even when we are changing the order the first project builds successfully leaving the subsequent project dependent on BundleMinifier to fail

Please provide us a solution to move ahead
logs_12961.zip

We too are facing this issue. The build fails when there is another build in the same definition that uses this BundleMinifier.

The first project succeeds and the next build fails, irrespective of the sequence of the two projects.

I'm seeing this in my Noda Time builds. This is with .NET Core 2.1 GA (so 2.1.300) and without TFS being involved - just running the build from a bash script. Happy to help diagnose if I can.

I'm still investigating this (as best I can - at a conference over dodgy wifi) but I have a sneaking suspicion it may be related to MS Build node reuse.

It may be worth anyone having issues with this disabling node reuse by setting the environment variable MSBUILDDISABLENODEREUSE=1 in their build script. That's what I'm trying now for Noda Time...

Thread - let me know if someone submits PR that fixes and I'll merge it promptly.

In my case, this was actually caused by the use of a global variable with strict mode enabled. Instead of reporting the error, the build just broke. Maybe try running jshint on your sources before you build to try to pick up anything that could cause the bundler to break?

Just dropping in to say that setting the environment variable MSBUILDDISABLENODEREUSE=1 did the trick for me. THANK YOU @jskeet!

I had two web projects using BuildBundlerMinifier. Given a clean checkout with VS closed, dotnet build would produce the minified css then throw the ContextID error. Running immediately afterward, it would produce the minified js and throw the error. Running a third time would finish successfully. I tried every combination of including different files, producing only one minified file or the other and everything else I could think of and only this environment variable value fixed it for me.

I needed the dotnet CLI to work since we're using TeamCity for our build pipeline. Fortunately, TC makes it easy to set an environment variable for a single build config.

This is really frustrating. Has there been any progress on improved error reporting? I started to get this issue when I updated Core. I did not even change anything in my JS!

So, I am not sure which did it for me, but I cleaned up my bundled assets a bit, I enabled TieredCompilation and LangVersion latest.

I am thinking it was cleaning up my bundled assets. I added .min after all of them which had min files (like bootstrap) and I disabled renameLocals.

So all in all, I did not make many changes and that got it working again.

@jskeet My build agent is on Linux (Ubuntu), and I'm also hitting this problem.
How do you set MSBUILDDISABLENODEREUSE on Linux?

@shaulbehr: It's just an environment variable:

export MSBUILDDISABLENODEREUSE=1 

Just encountered this again randomly today. Disabled all the minify stuff for my css and that fixed it. Or maybe retrying a few times fixes it. At this point I truly don't know. I also find MSBUILDDISABLENODEREUSE=1 to work, but personally I dont think its an acceptable "fix". Huge performance hit to turning that on. Plus ill have to document so future devs dont see it and wonder wtf it does.