RicoSuter/DNT

Unexpected winfx errors

Open

#31 建立於 2019年2月8日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)C# (74 fork)github user discovery
help wanted

倉庫指標

Star
 (470 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

When running dnt switch-to-projects switcher.json I get for every csproj the following error:

The project '...\TestProject.csproj' could not be loaded: The imported project "E:\Microsoft.WinFx.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:\Program Files (x86)\MSBuild\14.0\Bin\Microsoft.WinFX.targets

This targets file contains the following import statement:

It looks like the variable $(MSBuildFrameworkToolsPath) is not set.

Any why is DNT taking the targets file from the Visual Studio 2015 (14.0) context?

My setup:

  • Visual Studio 2017 15.9.6
  • Visual Studio 2015 aside

λ dotnet --info .NET Core SDK (reflecting any global.json): Version: 2.1.503 Commit: 4c506e0f35

Runtime Environment: OS Name: Windows OS Version: 6.3.9600 OS Platform: Windows RID: win81-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.503\

Host (useful for support): Version: 2.1.7 Commit: cca5d72d48

Source code analysis Potential issue with the following code: image

This code resolves to a location on C-drive whereas I have the bits residing at D-drive. We need to fix the msbuild resolving logic. Potentially reading from registy location. See https://stackoverflow.com/questions/328017/path-to-msbuild

Or maybe better to leverage the .NET Core SDK using msbuild.dll e.g. in path C:\Program Files\dotnet\sdk\2.1.503. Is there an API? E.g. https://github.com/dotnet/cli/blob/release/2.1.502/src/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs

I don't think this will work because the legacy csproj files are referring targets that are not present within the .NET Core context:

  • Microsoft\VisualStudio\v10.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets
  • Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets

Ultimately ToolLocationHelper.GetPathToBuildToolsFile should work in a .NET Core context as well, ref https://github.com/Microsoft/msbuild/issues/4013

貢獻者指南