nuget vs2015 Cannot Resolve Group Target Dependicies Correctly - visual-studio

I use visual studio 2015 and when I want to use a nuget package(includes .netcore and .net versions both) from my .net45 project that time nuget package manager try to resolve .netcore depencies and failed.What I am waiting if my project is .net45 that time only try to resolve target framework 4.5 depencies but nuget try to resolve .NETStandard1.3 dependecies too. Am I missing something or is this design behaviour of nuget?
nuspec file like that
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="librdkafka.redist" version="0.11.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETFramework4.6">
<dependency id="librdkafka.redist" version="0.11.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard1.3">
<dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" />
<dependency id="librdkafka.redist" version="0.11.0" exclude="Build,Analyzers" />
<dependency id="System.Console" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Linq" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Runtime.InteropServices" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Runtime.Extensions" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Threading" version="4.3.0" exclude="Build,Analyzers" />
</group>
</dependencies>

nuget vs2015 Cannot Resolve Group Target Dependicies Correctly
According to the troubleshooting on above comments, you need update your nuget extensions after the 2.12 version. That because starting with nuget 2.12, nuget support full NetStandard and NetCoreApp. You can refer to the nuget release note for 2.12:
•Full NetStandard and NetCoreApp support for VS2013
So, to resolve this issue, please update your nuget extensions first.

Related

Errors trying to submit VSIX extension to Visual Studio Marketplace

I created a Roslyn Analyzer/Code Fix Vsix for Visual Studio 2022. If I run it locally, it installs into VS and works fine.
I tried to submit to Visual Studio Marketplace and got an error stating: Target 'Microsoft.VisualStudio.Community' with version range '[17.0,18.0)' requires specifying a product architecture.
So in the .vsixmanifest file, I replaced:
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,18.0)" />
</Installation>
with
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
However, now, when I recompile I get Error VSSDK1062 Schema validation error for ... The 'http://schemas.microsoft.com/developer/vsx-schema/2011:Dependencies' element is not declared. and same for Assets element. However, both elements are there in the file:
What am I missing?
.vsixmanifest:
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="AnalyzerFoo.67e73b27-47db-43ce-a4d0-b4a540217728" Version="1.0" Language="en-US" Publisher="Frank Rizzo"/>
<DisplayName>Foo Code Fix for Visual Basic</DisplayName>
<Description xml:space="preserve">Use Explicit Type code fix for Visual Basic (like in C#)</Description>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Dependencies>
<Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
</Dependencies>
<Assets>
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="AnalyzerUseExplicitType" Path="|AnalyzerUseExplicitType|"/>
<Asset Type="Microsoft.VisualStudio.Analyzer" d:Source="Project" d:ProjectName="AnalyzerUseExplicitType" Path="|AnalyzerUseExplicitType|"/>
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="AnalyzerUseExplicitType.CodeFixes" Path="|AnalyzerUseExplicitType.CodeFixes|"/>
<Asset Type="Microsoft.VisualStudio.Analyzer" d:Source="Project" d:ProjectName="AnalyzerUseExplicitType.CodeFixes" Path="|AnalyzerUseExplicitType.CodeFixes|"/>
</Assets>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,18.0)" DisplayName="Visual Studio core editor" />
<Prerequisite Id="Microsoft.VisualStudio.Component.Roslyn.LanguageServices" Version="[17.0,18.0)" DisplayName="Roslyn Language Services" />
</Prerequisites>
</PackageManifest>

NetCore 3.1 Project reference converted to package reference when packing

I have netcore 3.1 Console application with a Package Reference and a Project Reference.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>MyPackageId</PackageId>
<Product>MyProduct</Product>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyName>MyAssemblyName</AssemblyName>
<Version>1.0.1</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Options" Version="6.6.0.161" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MyUtilityProject.csproj" />
</ItemGroup>
</Project>
I would expect the pack function to reference the compiled dll's from MyUtilityProject, but instead it looks up the version from MyUtilityProject.csproj and converts it into a package reference.
Here is the generated .nuspec file:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>MyPackageId</id>
<version>1.0.1</version>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<dependencies>
<group targetFramework=".NETCoreApp3.1">
<dependency id="MyUtilityProject" version="2.13.0" exclude="Build,Analyzers" />
<dependency id="Mono.Options" version="6.6.0.161" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src=".\MyProduct\bin\Debug\netcoreapp3.1\MyProduct.runtimeconfig.json" target="lib\netcoreapp3.1\MyProduct.runtimeconfig.json" />
<file src=".\MyProduct\bin\Debug\netcoreapp3.1\MyProduct.dll" target="lib\netcoreapp3.1\MyProduct.dll" />
</files>
</package>
How do I convince the VS build job, that it should include the dll's and not reference the package?
The resolution to my problem was adding
<PackAsTool>true</PackAsTool>
to the project file.
I guess it was not quite clear from my question, that I was trying to build a tool, except for the fact that OutputType is exe.
This leads to the conclusion, that MicroSoft assumes that if you push a packet, all referenced projects are also pushed as packages.

VS2017 nuget keeps searching for packages in wrong location

So I migrated from nuget packages.config to PackageReference and found out there were some compatibility issues. I reverted the project to its working state (before the PackageReference) and now my project is not compiling.
I get the following error:
Severity Code Description Project File Line Suppression State
Error The package EntityFramework with version 6.2.0 could not be found in C:\Users\user.nuget\packages. Run a NuGet package restore to download the package. DbManager
This happened to multiple packages. It seems that Nuget is searching for packages in the user.net\package directory for some reason. Originally, there was a folder within the project that contained all the packages.
I forced the global path to be at the folder within the project by editing the NuGet.Config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="C:\Projects\App\App Source\packages\" />
<add key="globalPackagesFolder" value="C:\Projects\App\App Source\packages\" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
</configuration>
I don't know why Nuget keeps looking for packages at that location. It should be looking at the packages folder within the project.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net46" />
<package id="EntityFramework6.Npgsql" version="3.1.1" targetFramework="net46" />
<package id="Npgsql" version="3.2.7" targetFramework="net46" />
<package id="System.Threading.Tasks.Extensions" version="4.3.0" targetFramework="net46" />
<package id="Z.EntityFramework.Plus.EF6" version="1.7.17" targetFramework="net46" />
</packages>
All of these packages in packages.config are not being found. This problem started happening when I tried PackageReference.
Is there any way to reset Nuget's settings? I would appreciate any guidance in solving this problem.
TLDR; This is caused by latent copies of the new project.assets.json file being left in your /obj/ folders. These can be safely deleted.
You can run this Powershell (at your own risk) in your root solution folder as a quick way to purge these files:
ls project.assets.json -Recurse | foreach {rm $_}
project.assets.json is generated for projects using PackageReference to cache the Nuget dependency graph for your project. It seems to confuse Visual Studio/Nuget if it's left there even if your project is using (or reverted back to using) packages.config
This can happen in Visual Studio 2019 as well, if you try PackageReference and then revert back to packages.config (or even if you switch between Git branches with one Nuget restore method versus the other).
Further Info
More info on project.assets.json here:
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x

Windows 10 IOT Foundation namespace is missing IOT

We are trying to add iot capabilities to our Package.appxmanifest for a cordova project. Visual studio complains that the capability we are trying to use cannot be found nor is it a child of the foundation name space.
The underlined iot:Capability shows the following when hovered over:
The element 'BackgroundTasks' in namespace 'http://schemas.microsoft.com/appx/manifest/foundation/winows10' has invalid child element 'Capabilities' in namespace 'http://schemas.microsoft.com/appx/manifest/iot/windows10'. List of possible elements expected: '...
The thing is I created this as a new project and let vs do all the work yet it cannot resolve it's own entries it's creating. We see this with both a new C# and JS project that VS generated. Can anyone help us? (Yes we added the references "Windows IoT Extensions for the UWP" 10.0.10586.0 to the project as well.). FYI We get the same error when adding as well.
Here's the package.appxmanifest:
<?xml version='1.0' encoding='utf-8'?>
<Package IgnorableNamespaces="uap mp iot" xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10">
<Identity Name="com.project.syndication.sitepad" Publisher="CN=$username$" Version="2.0.0.0" />
<mp:PhoneIdentity PhoneProductId="a885d1d0-453e-11e6-a59d-550bfa336405" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>SitePad App</DisplayName>
<PublisherDisplayName>ERT</PublisherDisplayName>
<Logo>images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily MaxVersionTested="10.0.10586.0" MinVersion="10.0.10586.0" Name="Windows.Universal" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="com.project.syndication.sitepad" StartPage="ms-appx-web:///www/index.html">
<uap:VisualElements BackgroundColor="#464646" Description="CordovaApp" DisplayName="SitePad App" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png">
<uap:SplashScreen Image="images\splashscreen.png" />
<uap:DefaultTile ShortName="SitePad App" Square310x310Logo="images\Square310x310Logo.png" Square71x71Logo="images\Square71x71Logo.png" Wide310x150Logo="images\Wide310x150Logo.png" />
</uap:VisualElements>
<uap:ApplicationContentUriRules>
<uap:Rule Match="ms-appx-web:///" Type="include" WindowsRuntimeAccess="all" />
</uap:ApplicationContentUriRules>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<uap:Capability Name="picturesLibrary" />
<iot:Capability Name="systemManagement" />
</Capabilities>
</Package>
The hovering error looks like a bug with something(VS?), I'm seeing it multiple times, yet my code still compiles and runs OK.
No worries on this.

NuGet Package custom package path

I want NuGet to automatically download missing packages to a packages location outside of the solution 'globalpackages' folder. I have amended the NuGet.Config file as per [this help page][1].
My solutions's NuGet.Config file:
<configuration>
<solution>
<!-- Disable source control integration of packages folder -->
<add key="disableSourceControlIntegration" value="true" />
</solution>
<config>
<!-- Repository packages folder path -->
<add key="repositoryPath" value="$\..\..\globalpackages" />
</config>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
</configuration>
When looking in a project's .csproj file, the following references still exist:
<Reference Include="C5">
<HintPath>..\packages\C5.2.2.5073.27396\lib\portable-net40+sl50+wp80+win\C5.dll</HintPath>
</Reference>
This is pointing to the wrong folder. Do I need to hard-update each of these references for each project?
I am using Visual Studio 2013 and NuGet 2.8
Do not hard update each of the NuGet references. Just delete them and add the packages again.

Resources