This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We should prefer the task directory over the AppDomain base, since
AppDomain will point to MSBuild's path.
Undo portion of 1a79896 that removed
System.Collections.Immutable. The current fix will work in both MSBuild
versions which include Immutable as well as do not.
Replaces previous fix for https://github.com/dotnet/corefx/issues/31925.
There are two potential causes for the issue:
The first issue is simply a bug. We were probing the AppDomain base directory before looking next to the task. MSBuild tasks run in a shared appdomain and this points to the MSBuild bin directory. As a result we would start unifying to the MSBuild version for mismatches, but load our local copy for exact matches. The result was code we compiled didn’t unify with our dependencies (since those used older versions).
The second issue is more insidious. Our tasks are built under the assumption that we’ll unify all the code to the assembly version the task carries with it. We can guarantee this for code we compile since we’ll include the exact version of the dependency next to the task. We’ll either load that version, or an equivalent version that’s already been loaded or present in the GAC. We cannot garuntee this for code we aren’t compiling, and we bank on the fact that nothing in the normal probing will find that old assembly. If it does, we’ll be back in this place. An added wrinkle to this is that if one of the assemblies we depend on ourselves was already loaded by someone else in the same appdomain and during that load msbuild or the task that loaded it unified its dependency to a different version we can’t change that and we’re stuck with the different version, and thus it won’t unify to what’s already been loaded.
Now the cases folks just started hitting are all 1. The fix will be to simply fix that bug. We need to do so carefully so that we don’t trigger issue 2.
Issue 2 is always present with MSBuild tasks (consider the GAC), it just became a bit more prevalent now that MSBuild put one of our dependencies inbox. We just need to make sure either 1) we either compile against the exact same version that MSBuild has so that even if someone pre-loads it we’re fine since we’ll unify to that anyway, 2) None of our dependencies reference that version, so we’ll never pre-load it.
Here's the set of versions that we know MSBuild included:
Here’s the current set we’re using in master of buildtools:
So currently we are “safe” because the only two overlapping versions are in assemblies we control and they match exactly. We can either keep them at 1.2.3.0, or update them to a new version and remain safe. We’ll have to be careful when taking updates to dependencies that they do not bring in dependencies on 1.2.1.0 (or 1.2.3.0 if we happen to move to a newer version).
This actually raises the issue that MSBuild should be careful about changes it makes to the binaries in the probing paths as those change could easily break existing tasks.