dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.9k stars 783 forks source link

15.8 Internal MSBuild Error #5504

Closed asik closed 6 years ago

asik commented 6 years ago

Upgrade from 15.7.6 to 15.8 Open solution Build (Rebuild, Clean/Rebuild, whatever)

1>------ Rebuild All started: Project: ****, Configuration: Debug Any CPU ------ 2>------ Rebuild All started: Project: ****, Configuration: Debug Any CPU ------ 2>Unhandled Exception:MSB0001: Internal MSBuild Error: Already registered for build-time. 2>Error: MSB0001: Internal MSBuild Error: Already registered for build-time..

I emptied all VS cache folders and ran a repair install, no luck. I could repro with a dummy solution with just an empty console app and 2 empty libraries, all on .NET Framework (not .NET Core or Standard). However after closing and reopening VS on that solution, I could no longer repro. ConsoleApplication2.zip

I can always repro on our solution with 90+ projects (mix F#/C#, all .NET Framework).

Tools->Options->Projects and Solutions->Build and Run-> Reducing the number of parallel projects to 1 was a workaround.

Another weird thing I noticed is that in the Project Properties->Application, the Target Framework dropdown is empty:

image

Since this version seems completely broken and I need to work, I'm going to downgrade to the previous release using these instructions https://docs.microsoft.com/en-us/visualstudio/productinfo/installing-an-earlier-release-of-vs2017

EDIT: The problem is gone after reverting back to 15.7.6.

cartermp commented 6 years ago

This is currently being looked into, though when I open the repro solution and build on my machine, it succeeds:

(big log elided)
3>Target "PrepareForRun" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "C:\Users\phcart\Downloads\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.fsproj" (target "CoreBuild" depends on it):
3>Target "_CleanGetCurrentAndPriorFileWrites" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "C:\Users\phcart\Downloads\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.fsproj" (target "IncrementalClean" depends on it):
3>Target "IncrementalClean" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "C:\Users\phcart\Downloads\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.fsproj" (target "CoreBuild" depends on it):
3>Target "CoreBuild" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "C:\Users\phcart\Downloads\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.fsproj" (target "Build" depends on it):
3>Target "AfterBuild" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "C:\Users\phcart\Downloads\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.fsproj" (target "Build" depends on it):
3>Target "Build" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" from project "C:\Users\phcart\Downloads\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.fsproj" (entry point):
3>Done building project "ConsoleApplication2.fsproj".
3>
3>Build succeeded.
========== Build: 3 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
cartermp commented 6 years ago

I can reproduce the target framework dropdown being empty, though.

cartermp commented 6 years ago

For posterity

MSBuild issue: https://github.com/Microsoft/msbuild/issues/3610 Devcom issue: https://developercommunity.visualstudio.com/content/problem/311575/exceptionmsb0001-internal-msbuild-error-already-re.html

Labeling this as external unless we get confirmation that is an issue on our side. If it's determined that this is not in our own code, we'll close this as an external bug.

BentTranberg commented 6 years ago

I'm having this issue after upgrading to VS 15.8.0, and I have a feeling many developers will report this in the next few days. Although it looks like an external issue, I also suspect it is strongly related to F#. I found one issue on SO, and there was a mix of F# and C#. Also found another older issue (probably other cause then) on developercommunity.visualstudio.com where a mix of F# and C# is mentioned. Haven't googled thoroughly. Then I follow the first link above, and there too a mix of F# and C# is mentioned. So I hope we (the F# community) push for a quick solution to this. The workaround works, but it slows down builds considerably. (edit: My second machine was updated to 15.8.1, and don't have the problem. My first machine was updated from 15.8.0 to 15.8.1 and still has the problem.) (edit2: Both machines have the problem.)

Savelenko commented 6 years ago

I also came across this issue, on two different machines after upgrade to VS 15.8 on .NET Framework.

hejoco commented 6 years ago

Experiencing same issue after upgrading to 15.8. My solution has one C# project and three F# projects. The error message always complains about the same F# project. All F# projects have empty Target Framework.

cartermp commented 6 years ago

After a thorough investigation with the MSBuild and Project System teams, we've identified the sources of the problem and a few possible fixes. The cheapest one we arrived at would involve changing the F# classic project system, so we'll be doing that (hence the label change). The issue arises when this condition is met.

We're currently working on a fix, but we'll need to assess the impact of that fix before pushing anything.

BentTranberg commented 6 years ago

I doubt the following is useful information, but just in case it is. Not a practical problem for me - just an observation.

I have set the number of concurrent builds to 1, as a workaround for this issue, which affects all my solutions on all machines. Mix of C#/F#/Framework/Standard/Core. It has worked flawlessly until now. When I tried to add a package with NuGet (not Paket), I got one set of these errors (they come in pairs as shown in the top post here) in spite of the workaround. Retrying solved it there and then.

ghost commented 6 years ago

@cartermp What is the status of this?

cartermp commented 6 years ago

@curdincaspar There is a fix out at #5557, but @KevinRansom is currently fixing CI before that can be merged.

cartermp commented 6 years ago

Now that the fix is merged, users with the nightly builds can see it. We'll be striving for a servicing fix for 15.8 and also merging this into the 15.9 branch. We'll report back when we have more detailed information.

KevinRansom commented 6 years ago

Let's close when it's inserted into a shipping branch.

cartermp commented 6 years ago

This has been inserted and shipped in 15.8.5.