novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
347 stars 42 forks source link

Error message when adding references in VS2017 UI #144

Closed BrianDT closed 5 years ago

BrianDT commented 5 years ago

Adding project references in the project file is fine but trying to add them in the VS 2017 UI generates an error. Right click on Dependencies and select ‘Add Reference …’ and the error ‘Missing value for TargetPlatformMDLocation property’ is displayed. error message capture

BrianDT commented 5 years ago

Should have said its a simple uap10.0 sample project

<Project Sdk="MSBuild.Sdk.Extras/1.6.65">

  <PropertyGroup>
    <TargetFramework>uap10.0</TargetFramework>
    <TargetPlatformVersion>10.0.17134.0</TargetPlatformVersion>
    <TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\SdkP1.UWP\SdkP1.UWP.csproj" />
  </ItemGroup>

</Project>
clairernovotny commented 5 years ago

Unfortunately, this is a bug in the VS tooling. It cannot add a reference to a multi-targeted project in the UI. As a workaround, you can add it manually in the project file as XML using the ProjectReference item.

Please file an issue on the Report a Problem tool in VS to help get more attention to it.

@ridomin

BrianDT commented 5 years ago

Hi Oren,

Would you mind clarifying a bit, because I feel that there must be more than just multi-targeting that is causing the issue.

If I have a project like

netstandard2.0;netstandard1.4;net462

This has no problem adding the project reference in the UI.

Or am I misinterpreting what is implied by ‘multi-targeted’?

Thanks Brian

Sent from Mail for Windows 10

From: Oren Novotny Sent: 26 December 2018 14:53 To: onovotny/MSBuildSdkExtras Cc: Brian; Author Subject: Re: [onovotny/MSBuildSdkExtras] Error message when adding referencesin VS2017 UI (#144)

Unfortunately, this is a bug in the VS tooling. It cannot add a reference to a multi-targeted project in the UI. As a workaround, you can add it manually in the project file as XML using the ProjectReference item. @ridomin — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

jimpierson commented 5 years ago

@BrianDT

I haven't fully tested whether this screws things up later down the line.... but I added the following 'Directory.Build.Props' to my local copy of Prism in the 'Windows10' folder. I have several extensions I've written and the above bugged the hell out of me!!!! Add Reference now works and everything 'appears' to compile correctly.... :)

`

<PropertyGroup>
    <TargetPlatformWinMDLocation>C:\Program Files (x86)\Windows Kits\10\UnionMetadata</TargetPlatformWinMDLocation>
</PropertyGroup>

`

BrianDT commented 5 years ago

The suggestion to define the WinMDLocation is a good one. Doesn’t look like it will work as defined above in a MSBuild.Sdk.Extras style project, but there is no problem adding the line-

C:\Program Files (x86)\Windows Kits\10\UnionMetadata

Directly into the project file, and this does resolve the issue. Wonder why this was not done automatically when defining the target framework as uap10.0