Reference older MSBuild for .NET Framework tasks#26080
Reference older MSBuild for .NET Framework tasks#26080joeloff merged 1 commit intodotnet:release/6.0.4xxfrom
Conversation
|
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
|
Do we need more changes? I'm seeing different missing method exceptions now in the Helix logs |
This fixes a class of break in the scenario "New .NET SDK running on old Visual Studio/ MSBuild.exe" by ensuring that the SDK task assemblies don't get references to newer versions of MSBuild's transitive references than are available in the current MSBuild environment, even if that's older. We have to specify explicit old versions of some `System.*` assemblies to get versions that will be consistent with the older versions of MSBuild.
da868fd to
cbc6080
Compare
|
@joeloff sorry, latest push should be a bit better! |
|
@dtivel Any idea why the PEM tests are failing on Linux. Has anything changed you're aware of? It's finding the file, just not the certificate, but finding the certificate on Windows. |
|
@joeloff, I'm not aware of any changes. How can I debug this failure? |
WSL is the only option I know of, so I'm going to try and repro this. I tried the following: using System.Security.Cryptography.X509Certificates;
X509Certificate2Collection _certificates = new();
_certificates.ImportFromPemFile("/mnt/c/git/forks/sdk/src/Layout/redist/trustedroots/codesignctl.pem");
var results = _certificates.Find(X509FindType.FindByThumbprint, "0563b8630d62d75abbc8ab1e4bdfb5a899b24d43", validOnly: true);
foreach (var r in results)
{
Console.WriteLine($"{r.SubjectName.Name}");
}and it finds the certificate and prints the information |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |

Updates of MSBuild's transitive references have caused insertion breaks twice now, in #25507 and #25897. Both happened because, in older-but-still-supported Visual Studio environments, MSBuild's binding redirects mismatched what the task's compilation environment provided, causing some types to be resolved from an older version of an assembly and some types to be resolved from a newer, creating mismatches at runtime.
I initially "fixed" this by manually downgrading some of the transitive references at SDK compilation time in 66826cc. But that is confusing, labor-intensive, and hard to maintain.
This is a different solution: explicitly target the version of MSBuild that the tasks are expected to run on. MSBuild's compatibility guarantees are such that tasks compiled for an older MSBuild should always work, so this should be safe, and it more accurately reflects the intent of the SDK tasks: they should work on older MSBuild (and thus Visual Studio).