madskristensen / BundlerMinifier

Visual Studio extension
Other
616 stars 172 forks source link

Internal MSBuild Error: ContextID 72 should have been in the ID-to-project file mapping but wasn't! #457

Open WereDev opened 4 years ago

WereDev commented 4 years ago

Installed product versions

Description

When building from a clean state (eg after dotnet clean), I get the error as indicated in the title. On a subsequent build, it builds fine and produces the minified file

Steps to recreate

  1. Get fresh clone of repo or run dotnet clean
  2. run dotnet build

Current behavior

It throws this error the first time, and works the second time.

Expected behavior

It should work the first time minimizing the appropriate file, or at least provide an error that makes sense should there be a problem with the bundleconfig.json

WereDev commented 4 years ago

Full contents of error received:


Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 33.48 ms for /home/daniel/code/weredev.com/Weredev.Providers.Flickr/Weredev.Providers.Flickr.csproj.
  Restore completed in 33.63 ms for /home/daniel/code/weredev.com/Weredev.UI/Weredev.UI.csproj.
  Restore completed in 33.48 ms for /home/daniel/code/weredev.com/Weredev.UI.Domain/Weredev.UI.Domain.csproj.
  Restore completed in 33.48 ms for /home/daniel/code/weredev.com/Weredev.Providers.GitHub/Weredev.Providers.GitHub.csproj.
  Weredev.UI.Domain -> /home/daniel/code/weredev.com/Weredev.UI.Domain/bin/Debug/netcoreapp3.1/Weredev.UI.Domain.dll
  Weredev.Providers.Flickr -> /home/daniel/code/weredev.com/Weredev.Providers.Flickr/bin/Debug/netcoreapp3.1/Weredev.Providers.Flickr.dll
  Weredev.Providers.GitHub -> /home/daniel/code/weredev.com/Weredev.Providers.GitHub/bin/Debug/netcoreapp3.1/Weredev.Providers.GitHub.dll

  Bundler: Begin processing bundleconfig.json

Build FAILED.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.11
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: ContextID 72 should have been in the ID-to-project file mapping but wasn't!
   at Microsoft.Build.Shared.ErrorUtilities.ThrowInternalError(String message, Object[] args)
   at Microsoft.Build.BackEnd.Logging.LoggingService.GetAndVerifyProjectFileFromContext(BuildEventContext context)
   at Microsoft.Build.BackEnd.Logging.LoggingService.LogBuildEvent(BuildEventArgs buildEvent)
   at Microsoft.Build.BackEnd.TaskHost.LogErrorEvent(BuildErrorEventArgs e)
   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)
   at BundlerMinifier.BundlerBuildTask.BundleMinifier_ErrorMinifyingFile(Object sender, MinifyFileEventArgs e)
   at BundlerMinifier.BundleMinifier.OnErrorMinifyingFile(MinificationResult result)
   at BundlerMinifier.BundleMinifier.MinifyBundle(Bundle bundle)
   at BundlerMinifier.BundleFileProcessor.ProcessBundle(String baseFolder, Bundle bundle)
   at BundlerMinifier.BundleFileProcessor.Process(String fileName, IEnumerable`1 bundles)
   at BundlerMinifier.BundlerBuildTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
   at Microsoft.Build.BackEnd.TaskBuilder.InitializeAndExecuteTask(TaskLoggingContext taskLoggingContext, ItemBucket bucket, IDictionary`2 taskIdentityParameters, TaskHost taskHost, TaskExecutionMode howToExecuteTask)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteBucket(TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Dictionary`2 lookupHash)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(TaskExecutionMode mode, Lookup lookup)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(TargetLoggingContext loggingContext, BuildRequestEntry requestEntry, ITargetBuilderCallback targetBuilderCallback, ProjectTargetInstanceChild taskInstance, TaskExecutionMode mode, Lookup inferLookup, Lookup executeLookup, CancellationToken cancellationToken)
   at Microsoft.Build.BackEnd.TargetEntry.ProcessBucket(ITaskBuilder taskBuilder, TargetLoggingContext targetLoggingContext, TaskExecutionMode mode, Lookup lookupForInference, Lookup lookupForExecution)
   at Microsoft.Build.BackEnd.TargetEntry.ExecuteTarget(ITaskBuilder taskBuilder, BuildRequestEntry requestEntry, ProjectLoggingContext projectLoggingContext, CancellationToken cancellationToken)
   at Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(ITaskBuilder taskBuilder)
   at Microsoft.Build.BackEnd.TargetBuilder.BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, String[] targetNames, Lookup baseLookup, CancellationToken cancellationToken)
   at Microsoft.Build.BackEnd.RequestBuilder.BuildProject()
   at Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport()
   at Microsoft.Build.BackEnd.RequestBuilder.RequestThreadProc(Boolean setThreadParameters)

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: ContextID 72 should have been in the ID-to-project file mapping but wasn't!
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, Boolean graphBuild, String[] inputResultsCaches, String outputResultsCache)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
Unhandled exception. Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: ContextID 72 should have been in the ID-to-project file mapping but wasn't!
   at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, Boolean graphBuild, String[] inputResultsCaches, String outputResultsCache)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
   at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)```
orphisAG commented 4 years ago

I have the same issue, did you find a solution?

zbecknell commented 4 years ago

For anyone encountering this that wants a temporary solution, you can manually edit the BuildWebCompiler.targets file and tell the task to continue on error like so:

<Target Name="WebCompile" BeforeTargets="BundleMinify;BeforeCompile" Condition="'$(RunWebCompiler)' != 'False'">
    <WebCompiler.CompilerBuildTask FileName="$(MSBuildProjectDirectory)\compilerconfig.json" ContinueOnError="WarnAndContinue" />
</Target>

I had this problem when running dotnet watch run. The error would occur mostly on incrnemental builds after the first one, so this gets me up and running.