Coder Social home page Coder Social logo

Comments (4)

daveaglick avatar daveaglick commented on May 25, 2024

It looks like the target checks the "$(MSBuildThisFileDirectory)\tools\net46" folder for Microsoft.NET.Build.Extensions.Tasks.dll:

https://github.com/dotnet/sdk/blob/cd25d6bbfc2aac61cc790c511900427ac64fdaa8/src/Tasks/Microsoft.NET.Build.Extensions.Tasks/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.targets#L21

This folder exists at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\tools\net46" when Visual Studio is installed, but not at "C:\Program Files\dotnet\sdk\2.0.2\Microsoft\Microsoft.NET.Build.Extensions\tools" (the latter only has a "netcoreapp1.0" subfolder). However, we set the MSBuild extensions folder to the dotnet SDK path if we detect an SDK project.

I guess it makes sense that .NET Framework projects should be using the VS build chain. It is called the .NET Core SDK after all. Suspect we'll need to check if the project targets .NET Framework and use the FrameworkPathHelper if so.

from buildalyzer.

daveaglick avatar daveaglick commented on May 25, 2024

Interesting - it looks like the behavior is also different between an SDK project that targets net46 (which works) and one that targets net462 (which doesn't).

from buildalyzer.

dsplaisted avatar dsplaisted commented on May 25, 2024

MicrosoftMicrosoft.NET.Build.Extensions is used to support .NET Standard 2.0 when targeting .NET 4.6.1 and up. So it's not used if you're targeting .NET 4.6, because that doesn't support .NET Standard 2.0.

You should pretty much never use the targets in C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk. Those targets correspond to the 1.x version of the SDK, so they won't work if you're trying to target .NET Standard 2.0 or .NET Core 2.0 or higher, and also don't have any other updates that came in the 2.0 SDK or later. You should use the versions from C:\Program Files\dotnet\sdk\, even if the project targets .NET Framework.

However, I don't know if you need to explicitly point MSBuild to those targets. MSBuild has a built-in Sdk import resolver which will find those targets. I don't know if it will be automatically used when you are just using the MSBuild APIs. It is installed under C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\SdkResolvers, so you may want to point MSBuild at that resolver instead of pointing it directly at the SDK props and targets files (that way it will respect global.json and any other logic that is normally used to find those files).

from buildalyzer.

daveaglick avatar daveaglick commented on May 25, 2024

@dsplaisted Thanks a bunch, that does help. Especially the bit about a custom resolver. After popping it open in a decompiler I can see how the VS toolchain finds the SDK.

Based on what you said about the targets in the VS Sdks directory, I'll use the VS toolchain for building .NET Framework SDK projects but set MSBuildSDKsPath to the .NET Core SDK. Hopefully that'll give the right combination of targets for these types of projects.

from buildalyzer.

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.