none
NuGet update fails for Native C++ code

    Question

  • Hi

    I am trying to use NuGet packages for our libraries and use these to build our applications. I have successfully created the packages when the libraries are built and they get pushed to our local repository.

    Solutions which use these packages can successfully restore packages with the version of the package they were originally built with but I want to build with our latest libraries.

    I run NuGet.exe restore to restore the packages then run NuGet.exe update to get the latest version of the packages. The restore works fine but when I run NuGet.exe update on the visual studio solution I get the following error:

    WARNING: Could not install package 'GeneralLibPackage 1.0.15300.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    Both the package being installed and the project using the package are native C++ so neither use the .NET framework so I am not sure why I get this error and it fails, can ayone help me resolve this?

    There is no reference to <TargetFrameworkVersion> in the project file as it does not use the .NET framework so I cannot understand why NuGet thinks the project targets version 4.0?

    If I do an update through 'Manage NuGet Packages' in Visual Studio 2013 on my local machine it works fine but calling NuGet.exe update on the solution fails as descibed. The reason I need to use NuGet.exe is that I am trying to do this automatically as part of the build process on the build server using a PowerShell script.

    I am using NuGet version 3.2.0.

    Thank you
    Rich.

    Thursday, November 12, 2015 2:01 PM

Answers

  • Hi Rich,

    Thanks for your friendly response.

    I know that the MSBuild really is related to the .NET Framework, and it seems that the MSbuild has different versions in different VS IDE.

    https://msdn.microsoft.com/en-us/library/bb383796(v=vs.140).aspx

    https://msdn.microsoft.com/en-us/library/hh264221.aspx

    >>WARNING: Could not install package 'GeneralLibPackage 1.0.15300.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    Based on the previous error, maybe you could check that whether you use the correct MSbuild version or others in the .xxproj file.

    >>NuGet appears to be using MSBuild to determine the target framework of the application from the project file. It thinks it is a net4 application and fails to install the package.

    In addition, I also did some research about this issue, like this blog here:

    http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

    It seems that the old way to restore Nuget package was a part of MSbuild when we build our project, so it seems that you are correct, it really was related to the MSBuild, but maybe you could refer to the new way in the above document. Hope it could provide useful information for you.

    Sincerely,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 26, 2015 7:55 AM
    Moderator

All replies

  • Hi Rich,

    Not use any version control tool in my side, could you share me the detailed steps? How can I repro this issue in my local machine using the VS2013?

    >>I am using NuGet version 3.2.0.

    >>WARNING: Could not install package 'GeneralLibPackage 1.0.15300.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    Just to make this issue clearly, do you use the VS2013 in your previous machine which generated this error? As far as I know, the 3.2.0 version is in the VS2015, it is the 2.8 version in VS2013. So you could check that whether you use the appropriate version in your current VS IDE Environment.

    Maybe you could tell me the real VS version and the detailed steps you use, I will repro it in my side.

    As you said that it is related to the VC++ code, could you share me a simple sample using one drive?

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, November 14, 2015 9:36 AM
    Moderator
  • Hi Jack

    Thank you for your response, sorry for my delay in getting back to you.

    I am using VS2013 but we are just transitioning to VS2015. I have tried this with both Nuget version 3.2.0 and 2.8.6 and get the same type of error from both.

    I have done some reading around and it appears that MSBuild is reporting the .Net framework version for my native C++ project as v4.0. This appears to be the default if no <TargetFrameworkVersion> is specified in the project. Unfortunately this stops NuGet from updating the packages as it thinks they are incompatible. I cannot find any way round this.

    I have a C++ application that uses a static C++ library. The C++ library is put into a NuGet package.

    The C++ application is set up to use NuGet packages and has a packages.config file that refers to the last package version it was built with.

    This all works fine but when I call NuGet update on the solution file of the application I get the error described. NuGet appears to be using MSBuild to determine the target framework of the application from the project file. It thinks it is a net4 application and fails to install the package.

    Any ideas welcome.

    Best regards

    Rich.

    Wednesday, November 25, 2015 11:05 AM
  • Hi Rich,

    Thanks for your friendly response.

    I know that the MSBuild really is related to the .NET Framework, and it seems that the MSbuild has different versions in different VS IDE.

    https://msdn.microsoft.com/en-us/library/bb383796(v=vs.140).aspx

    https://msdn.microsoft.com/en-us/library/hh264221.aspx

    >>WARNING: Could not install package 'GeneralLibPackage 1.0.15300.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    Based on the previous error, maybe you could check that whether you use the correct MSbuild version or others in the .xxproj file.

    >>NuGet appears to be using MSBuild to determine the target framework of the application from the project file. It thinks it is a net4 application and fails to install the package.

    In addition, I also did some research about this issue, like this blog here:

    http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

    It seems that the old way to restore Nuget package was a part of MSbuild when we build our project, so it seems that you are correct, it really was related to the MSBuild, but maybe you could refer to the new way in the above document. Hope it could provide useful information for you.

    Sincerely,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 26, 2015 7:55 AM
    Moderator