novotnyllc / MSBuildSdkExtras

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

Warnings on <Sdk /> style import #97

Closed andrew-boyarshin closed 6 years ago

andrew-boyarshin commented 6 years ago

MSBuild warnings:

C:\Users\<user>\.nuget\packages\msbuild.sdk.extras\1.6.41\Sdk\Sdk.props(11,3): warning MSB4011: "C:\Program Files\dotnet\sdk\2.1.400-preview-009063\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props" cannot be imported again. It was already imported at "<project path>\project.csproj". This is most likely a build authoring error. This subsequent import will be ignored.
C:\Users\<user>\.nuget\packages\msbuild.sdk.extras\1.6.41\Sdk\Sdk.targets(15,3): warning MSB4011: "C:\Program Files\dotnet\sdk\2.1.400-preview-009063\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets" cannot be imported again. It was already imported at "<project path>\project.csproj". This is most likely a build authoring error. This subsequent import will be ignored.

Sample project:

<Project Sdk="Microsoft.NET.Sdk">
  <Sdk Name="MSBuild.Sdk.Extras" />
  <Sdk Name="Microsoft.Build.CentralPackageVersions" />
  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
  </PropertyGroup>
</Project>

I believe some checks are needed in Sdk\Sdk.props and Sdk\Sdk.targets not to import Microsoft.NET.Sdk if already imported, since <Sdk /> imports are valid scenario too (I believe they are much more maintainable than <Project Sdk="" />).

clairernovotny commented 6 years ago

Hi,

The extras should be in place of the Microsoft.NET.Sdk in the Project element. It will include that in the correct locations.

andrew-boyarshin commented 6 years ago

@onovotny of course I know that. The issue is about support of almost identical method: <Sdk />. It presents almost the same import behavior while preserving Project SDK.

clairernovotny commented 6 years ago

That cannot work though due to ordering requirements. The extras needs things both before and after the main SDK targets to work. Thats why it does the import.

andrew-boyarshin commented 6 years ago

I see. Makes sense. Still, that's unfortunate limitation. Linking msbuild issue for reference. Feel free to close this if you believe this is not an issue then.