GithubHelp home page GithubHelp logo

Comments (8)

rainersigwald avatar rainersigwald commented on August 15, 2024 1

There are two relevant things here:

  1. For applications that use the MSBuild API, we need to be able to load MSBuild from the SDK folder, so MSBuildLocator adds a resolver to find assemblies from there. This does not, however, override the runtime behavior that prefers to load assemblies "from next to the application" if they exist there.
  2. For MSBuild task plugins, we are (usually) running in an application from the SDK folder. We use AssemblyDependencyResolver to respect a .deps.json if the task provides one which should allow using a different version of one of our dependencies in the task's ALC.

This started with the first situation: mpc.exe shipped CodeDOM v6.0.0.0 but an MSBuild assembly loaded from the SDK directory wanted to load CodeDOM v8.0.0.0. Removing it from the app directory via ExcludeAssets="runtime" cleared that up.

I'm not completely sure why removing the CodeDOM deployment from next to the task caused failures there; the SDK copy should be just as available in that context.

from msbuild.

YuliiaKovalova avatar YuliiaKovalova commented on August 15, 2024

@vitek-karas, this issue can be interesting for you.
Before bumping to net8.0, there weren't any compatibility problems between used System.CodeDom net6.0 in the source project and net7.0 in MSBuild.

cc: @baronfel

from msbuild.

vitek-karas avatar vitek-karas commented on August 15, 2024

My guess would be that the problem is caused by:

 <PackageReference Include="System.CodeDom" ExcludeAssets="runtime" />

This brings in the 8.0 version of System.CodeDom but only as a compiler reference, it explicitly excludes it from the output. So when SDK builds this along with MSBuild - it will probably use the MSbuild's version (7.0) in the output. The end result is that you have a package/app which has code which references 8.0, but carries 7.0 as the implementation.

I don't know why the ExcludeAssets was added above.

That said there are other possible reasons, this involves custom ALCs and MSBuild's custom assembly resolution logic, so that might complicate things even more.

from msbuild.

YuliiaKovalova avatar YuliiaKovalova commented on August 15, 2024

cc: @AArnott

from msbuild.

AArnott avatar AArnott commented on August 15, 2024

@vitek-karas I added ExcludeAssets above, and it worked, because I don't reference System.CodeDom 8.0. I reference the 6.0 version. That makes it work with MSBuild whether MSBuild provides 6.0, 7.0, or 8.0 of the System.CodeDom dll.

The original failure was because I shipped the 6.0 assembly while MSBuild wanted 8.0. Because I shipped it, .NET loaded the 6.0 version, and refused to load the 8.0 version that MSBuild itself required.

from msbuild.

vitek-karas avatar vitek-karas commented on August 15, 2024

@AArnott oh - sorry, my bad. Thanks for the explanation. I missed the package version part of your PR.

@YuliiaKovalova if you want I can look into this some more, but I would need to know what is the project you're building - is it the message pack executable, or something else?

/cc @elinor-fung

from msbuild.

AArnott avatar AArnott commented on August 15, 2024

@vitek-karas for the repo @YuliiaKovalova links to, which I maintain, there are two front-ends that matter:

  1. An executable that uses MSBuildLocator.
  2. An MSBuild Task.

Both of these front-end projects depend on MessagePack.Generator.Core, a library that depends on System.CodeDom.dll.

from msbuild.

vitek-karas avatar vitek-karas commented on August 15, 2024

I guess this problem then happens when the MSBuild task is loaded into some msbuild execution. It doesn't carry System.CodeDom with it, and instead relies on the one from msbuild. That would explain the behavior above.

I don't know what's the detailed design of allowing msbuild tasks to carry their own versions of some of the msbuild dependencies - like System.CodeDom.

from msbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.