[Microsoft.Build.Engine] Fix race condition in TestTasks.dll compilation and embeddin...
commit6a8a2059bbbe68e183cec14f6c5bc3baeb4ae4cf
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Sun, 21 Oct 2018 00:09:37 +0000 (21 02:09 +0200)
committerGitHub <noreply@github.com>
Sun, 21 Oct 2018 00:09:37 +0000 (21 02:09 +0200)
tree6f8c5a6bbbfb683ae5f30a1199c781747aff5d22
parent4a6b11577fe06a58e6326b1c3a3bb58cfee6185c
[Microsoft.Build.Engine] Fix race condition in TestTasks.dll compilation and embedding (#11275)

Since we've started embedding test resources inside of the test assembly
we've sometimes seen a strange error on Jenkins during the test run:

```
Msg: Error initializing task StringTestTask: Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Msg: Error initializing task StringTestTask: System.TypeLoadException: Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
  at (wrapper managed-to-native) System.RuntimeType.GetConstructors_native(System.RuntimeType,System.Reflection.BindingFlags)
...
```

However this was from an xbuild_12 run so how come it tried to load xbuild 14 stuff?

The reason is there's a race condition between when TestTasks.dll gets
built and when it's embedded inside of the test assembly.

If we're building the xbuild_12 and xbuild_14 profile at the same time
we could end up embedding the xbuild_14 version of TestTasks.dll instead
of the correct one since we're copying it to the same file name.

The fix is to remove the unnecessary copying logic since we can just tell
the compiler to embed the file under the correct name.
mcs/class/Microsoft.Build.Engine/Makefile