jbienzms / iot-devices

Helper library for interfacing with devices in IoT projects.
45 stars 17 forks source link

'Windows.Devices.DevicesLowLevelContract' has already been imported #8

Closed dulfe closed 7 years ago

dulfe commented 8 years ago

Using the latest SDK (10.0.14393.0) the BUILD process fails with the error:

Error CS1704 An assembly with the same simple name 'Windows.Devices.DevicesLowLevelContract' has already been imported. Try removing one of the references (e.g. 'C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.DevicesLowLevelContract\1.0.0.0\Windows.Devices.DevicesLowLevelContract.winmd') or sign them to enable side-by-side.

and Warning:

Warning There was a conflict between two files. There was a conflict between two references with the same file name between the "WindowsIoT, Version=10.0.14393.0" and "WindowsIoT, Version=10.0.10240.0" SDKs. Choosing "C:\Program Files (x86)\Windows Kits\10\References\Windows.System.SystemManagementContract\2.0.0.0\Windows.System.SystemManagementContract.winmd" over "C:\Program Files (x86)\Windows Kits\10\References\Windows.System.SystemManagementContract\1.0.0.0\Windows.System.SystemManagementContract.winmd" because it was resolved first.

Steps to reproduce:

dulfe commented 8 years ago

I found a workaround!

First, I downloaded the "source" files and ran BuildAndPackage.cmd, that generated the new NuGet Packages (version 1.0.7).

I used those packages in a new project and the problem persisted.

So, I deleted the folder Packaging/Content and rerun BuildAndPackage.cmd, again, that generated a new NuGet Packages but this time those packages worked!... (I had to delete my NuGet Packages cache)

Daniel

jbienzms commented 8 years ago

Thanks for reporting this Daniel. Can you tell me a little more about what you think the root cause of the problem was? Do you feel the NuGet package that is published on NuGet.org is having problems with the latest version of NuGet or the runtime? Or do you think something might have gotten corrupt locally?

Oh, and just to be sure, have you gone to Extensions and Updates in Visual Studio to make sure you don't have a NuGet Package Manager update?

Thanks again!

dulfe commented 8 years ago

The folder Packaging/Content has a file named Microsoft.IoT.DeviceCore.targets which has:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <ItemGroup>
        <SDKReference Include="WindowsIoT, Version=10.0.10240.0">
          <Name>Windows IoT Extensions for the UWP</Name>
        </SDKReference>
      </ItemGroup>
    </Project>

I do not know much about how to create a NuGet package, but that seems like it is forcing the compiler to use the SDK 10.0.10240.0 instead of whatever the target project is using, so the compiler ends up trying to use both SDK and gets confused.

Without that file, the packages work fine.

And yes, I updated VS with all its extensions (including NuGet Package Manager)

Thank you for this great library! Daniel.

jyarbro commented 8 years ago

dulfe, I suggest you try setting the project properties target version for all of the lib projects to 14393 instead of 10240. This will probably resolve your issue. The version that comes out of this repository is still targeting 10240.

dulfe commented 8 years ago

@jyarbro , I tried that, ran BuildAndPackage.cmd and I had the same issue.... the only way I was able to fix it was deleting the file Microsoft.IoT.DeviceCore.targets.

My local copy is working, so I am OK for now. I hope it gets fixed in the next official release. Thank you!.

jbienzms commented 8 years ago

We can safely remove the targets file. I was trying to save users an extra step having to reference the UWP for IoT extension. But that never seemed to work well. It can be removed. I will do an update when I return from travels. Thank you both for your research on this. And thank you especially @dulfe for finding a solution!

jbienzms commented 8 years ago

I believe this issue has been fixed by @jyarbro in #9. Is that correct?

jbienzms commented 8 years ago

Actually, it looks like @jyarbro didn't touch the .targets or .nuspec like I thought he did. I'm sorry, I'll leave this open for now. And I apologize I haven't gotten to fixing it yet this week. If not this week I hope to early next week. I am trying to prepare for somewhat unexpected travel.

If either of you would like to update the nuspec and do a pull request I'd be happy to accept it. Then all I'd need to do is build an updated package and submit it to NuGet. If not, I'll try to get to it ASAP.

Thanks!

jyarbro commented 8 years ago

Yeah I didn't want to submit this particular change as I don't have a test environment exhibiting the flaw currently and no way to test if the change did anything.

PRIMETSS commented 7 years ago

or Changing the version # works too

`<?xml version="1.0" encoding="utf-8"?>

Windows IoT Extensions for the UWP `
jbienzms commented 7 years ago

Thanks very much to @dulfe for resolving the vast majority of these issues. I was finally able to get time today away from other responsibilities to test this across the board and build new NuGet packages. I also did some other cleanup. These changes are now incorporated in NuGet package 1.0.8 and later. Thank you again @dulfe, I'm closing this issue.