Microsoft.Windows.SDK.Contracts and Must Use PackageReference - nuget

It's been a while since I've gotten into nuget hell but I'm back to this again...
I'm not exactly sure what caused this issue other than I did a visual studio 2019 update before I left on Friday. Now today, I've been fighting an issue where my library won't compile due to "Must Use PackageReference".
I've found a few articles out there on this but nothing that seems to specifically address this problem.
This issue could also be due to accidentally adding some .netcore librairies (entity framework .core) to the .netframework library. I had a hard time removing those libraries using nuget.
I also tried to reload the nuget library by:
nuget-package -reinstall Microsoft.Windows.SDK.Contracts
That reloads the package ok, but when I recompile the library the error "Must use PackageReference" comes back again.
In the output window I have this when compiling:
...\path...\packages\Microsoft.Windows.SDK.Contracts.10.0.19041.1\build\Microsoft.Windows.SDK.Contracts.targets(4,5): error : Must use PackageReference
I'm not even seeing this referenced in any of my source files so I'm not sure I even need it. However, I can't uninstall it as it seems to have octopus tentacles in numerous other libraries.
What am I running into here and how do I get this resolved?

My fix was to convert the projects to PackageReference as seen here: https://learn.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference The problem went away after doing this and I haven't seen it since. Still a little uneasy on why this happened... But I don't have time to dwell on it.

Related

How to fix "The type or namespace name could not be found"?

Visual studio wont recognize certain packages (Entities, and TMPro, to name a few) and it gives the error: The type or namespace name could not be found; but everything compiles fine. I know there are already many questions and answers related to this problem, but so far none of them have worked for me.
So the way I downloaded these packages was by using the Unity Package Manager, so this makes things even more confusing because I installed other packages the same way, and they are recognized no problem.
So far I have tried:
Checking the target framework of the packages and the project (all are .NET Framework 4.6)
Deleting the Library folder
Checking my Unity version (2019.2.0a11)
Some extra notes:
I've had this issue for a long time now (with TMPro to be specific; for about a year) ever since downloading it from the Package Manager in one of the 2018.X versions
In other Unity projects, which are using various versions, give the same result. This leads me to believe it is something to do with my visual studio.
The Entities package shows up on the side, see picture below
I uninstalled Visual Studio 2017 installed Visual Studio 2019 and it fixed my problem. I suspect re-installing like others suggested may have worked too.

DLL will not be loaded due to errors

I am getting this error
Assembly ‘Library/ScriptAssemblies/Assembly-CSharp-Editor.dll’ will not be loaded due to errors: Reference has errors ‘Google.GData.Client’.
Our project was running on Unity 2018.1, and I am testing it on 2018.3.5f1. After doing some adjustments for the upgrade, I noticed that some of our custom MenuItem went missing and guessed that it's probably because of this error.
I have been searching about this since yesterday but had no luck finding the right solution. Any help is appreciated greatly.
Got it! I found some old libraries that are not used by our project anymore. In Unity 2018.3.x, .NET 3.5 is label as deprecated. For those who may encounter the same problems do the following:
Look for .dll files that targets .NET 3.5.
Either delete them, or update them.
Reopen Unity

AutoMapper 6.2.2 restore fails on VSTS build server

The Restore step fails in my build definition with this error:
error NU1100: Unable to resolve 'AutoMapper (>= 6.2.2)' for '.NETCoreApp,Version=v2.0'.
This is in a .NETCoreApp 2.0 that is using AutoMapper. Restore succeeds locally in VS 2017. Locally I am using dotnet sdk 2.0.0, and nuget 4.3.1. On the VSTS (cloud) server, I am specifying the latest nuget version, 4.5.0. I have tried many other versions, including 4.3.1 with no success.
I know there is an older, similar question here, but that was never answered satisfactorily, in my opinion.
If I look at the meta data in VS, at the top of one of the Automapper files I can see this:
Assembly AutoMapper, Version=6.2.2.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005
// C:\Users\randyg.nuget\packages\automapper\6.2.2\lib\netstandard1.3\AutoMapper.dll
From this you can see it's taking the netstandard1.3 version, which is correct. I'm wondering if the nuget on the build server is looking for a netcoreApp2.0 folder, rather than the netstandard1.3 folder? Following this theory, I tried adding this to my .csproj file:
<AssetTargetFallback>$(AssetTargetFallback);netstandard1.3</AssetTargetFallback>
My theory was this would tell nuget to look for a netstandard1.3 version of automapper if it couldn't find a netcoreapp2.0 version. However, this didn't have any effect. I later read that behind the scenes this fallback is already added automatically.
If anyone has any ideas I would greatly appreciate it. I'm pulling out (what's left of) my hair on this, as this is the only package giving me trouble, and it's a critical one for my project.
On the build server I'm using .NET Core sdk 2.0.3 as well, if that matters.
This is how I solved this: since it seemed it might have to do with my target being netcoreapp2.0, I tried adding an additional 'dummy' project to my solution, with its target = netstandard1.3. In this configuration, the restore/build succeeded. I thought I would have to maintain this dummy project for this purpose, until I tried deleteing it and now the netcoreapp2.0 solution still restores fine without it. I can only assume something was corrupted in the TFS build server NPM cache (even though I had tried checking the box to disable that cache), and once I got it to succeed once, it has cleared up whatever the issue was.

Issue with NuGet Package Manager

I have a project that I recently converted over to use Entity Framework. I installed the package on my development machine and everything worked perfectly and I continued to re-vamp the project.
I recently pushed out the first update to my production server with the Entity Framework code in it. When I tried to build the solution it threw all kinds of errors, namely this one over and over:
Could not resolve this reference. Could not locate the assembly "EntityFramework". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. bamblack.viewmodel
I went into my NuGet Package Manager, and it says EntityFramework was installed. I then tried to install it through the Package Manager Console, said the same thing. So I then tried to uninstall it. It says it can't locate the package!
I'm sure it's because I didn't do the actual install on the production machine and it's just missing a DLL somewhere, but I'm not sure where. If anyone could point me in the right direction that would be great.
Seems that all I needed to do was un/reinstall the references to EF on my development machine and push it out again. Strange that it didn't push them out the first time. Issue was resolved.

Netbeans compile error, why does it mean?

I finished a Netbeans project a few months ago, it was successfully done, finished. But the strange thing is today I happen to look into it and recompiled it, haven't changed anything, but got the following error, I vaguely remember I encountered similar situations before, just recompile and it will be fine, but not this time, I recompiled a few times, same error, restarted the PC, and recompiled again, same error :
build-impl.xml:501: copylibs doesn't support the "indexMetaInf" attribute
I never touched this file and have no idea why it worked fine, but failed this time, what's wrong and what's the fix ?
It seems that the problem is in version of Ant and new Ant attribute indexMetaInf.
I have the same problem and think it'll be worth to explain how I've got it.
How to obtain the problem:
I use NetBeans 6.8.
Recently I installed NetBeans 7.0. Just for acquaintance with new features.
I accepted to use old NB6.8 configuration, when NB7.0 asked me on the first launch.
That was mistake!
So. I started NB7.0 and my good old NB6.8 projects were there, in the projects list.
The problem is that NB7.0 not only imported my old projects in its projects list; but also
changed build-impl.xml of those projects.
And when I opened my projects in NB6.8 and tryed to compile them, there was that error with "indexMetaInf".
The essence of the problem:
In NB6.8 the Ant 1.7.1 is used, by default. And it seems that attribute "indexMetaInf" is only supported by
latest versions of Ant (maybe starting with 1.8.x). That new version of Ant was installed with NB7.0 and is used by NB7.0 only.
NB6.8 doesn't see it.
How to fix the problem:
I updated build-impl.xml file from subversion and it fixed the problem.
In my previous version of build-impl.xml there was no indexMetaInf.
Had the same problem, fixed it by copying the file org-netbeans-modules-java-j2seproject-copylibstask.jar from [netbeans]\java\ant\extra into the directory myProject\lib\CopyLibs
Strange thing happened again, this time good. I had a backup DVD, from a few weeks ago, I copied the project back, now it's compiling fine again, seems to me the project somehow got corrupted, I did a C: drive defragmentation last week, could it somehow moved some files around and messed up a bit ? Anyhow, not a problem now.
What platform are you using? I've had some odd errors like that on Unix due to trying to compile the project from the command line and having a older version of ant in my path.

Categories