CppWinRT wont generate headers for another nuget package - visual-studio

I'm trying to get this tutorial to work: port-to-nuget. (Note that cppwinrt provides the Windows.AI.MachineLearning namespace, but for quicker releases a different nuget package provides the Microsoft.AI.MachineLearning namespace)
Apparently the C++/WinRT toolkit is meant to pick up on the Microsoft.AI.MachineLearning NuGet package and generate the appropriate headers in the Generated Files\winrt folder.
However, I've tried creating a new console app, adding the CppWinRT and Microsoft.AI.MachineLearning nuget packages with the following code but am still getting the following error
fatal error C1083: Cannot open include file: 'winrt/Microsoft.AI.MachineLearning.h': No such file or directory
The following duplicate question doesn't help: Cannot open microsoft.ai.machinelearning.h from NuGet package

Related

Publish NuGet package without source code

I have a .NET project targeting .NET Standard 2.0. When compiled, this project yields an assembly in the ./bin/Debug/netstandard2.0 directory. I want to package this assembly into a NuGet package. However, I do not want to include the source code. In an attempt to do this, I currently am running the following from the command line:
dotnet build MyProject.csproj
dotnet pack --configuration Debug MyProject.csproj
dotnet nuget push bin/Debug/MyProject.1.0.0.nupkg --source https://nuget.pkg.github.com/my-organization --api-key [personal-access-token] --skip-duplicate --no-symbols true
The commands listed above successfully publish a NuGet package to my package registry. I can also successfully install this package via Visual Studio. However, when I attempt to compile the code, I get an error that says the namespace in the package cannot be found. I can see the package listed under the "dependencies/packages" node in Visual Studio. However, I cannot (or don't know how to) explore which namespaces are actually in it. But, when I right-click on it, and choose "Open Folder in File Explorer", I see the source code. I also see a *.nupkg file, a *.nupkg.sha512 file, and a .nupkg.metadata file.
My question is, how do I publish my NuGet package such that the source code is not included?
The dotnet pack would pack the code into a NuGet package. We recommend you use nuget.exe tool with .nuspec file, it could only pack your generated files.

Could not install package "System.Xml.XmlDocument 4.3.0", Does anyone knows the solution?

Error:
Severity Code Description Project File Line Suppression State
Error Could not install package 'System.Xml.XmlDocument 4.3.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', 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.
I have tried with below set of Trial and error methods but no luck.
1.Cleaned solution and Build/Rebuild Solution.
2.Deleted Packages and restored.
3.Deleted .vs folder and Tried.
4.Replaces System.XML with version 2.0.5 in Mono android file and tried.
5.Tried installing "System.Xml.XmlDocument" but Not allowing to install it and prompted below error
"Severity Code Description Project File Line Suppression State
Error Could not install package 'System.Xml.XmlDocument 4.3.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', 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."
6.Trying to add reference but not allowing to add reference.It Prompts below error
"Error HR has been returned from Call to a COM component"
7.Merged from iOS latest update but no use same error.
8.Removed empty System.Xml folder from object browser and checked.
9.Removed System.xml.dll and Reinstalled and checked.
10.Removed empty System.Xml.XmlDocument and reinstalled and checked.

Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'

Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar', in Xamarine Android . I am using Visual Studio 17.
And also
When i am intalling below package from Nuget Package Manager in Visual Studio 2017 for Xamarine.Android i am getting erorr below.
Error:
Could not install package 'Xamarin.Android.Support.v7.RecyclerView 27.0.2.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', 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.
It's probably a build issue, clean your solution, delete bin and obj folder and then rebuild, see if it persists.
You can also try restarting VS once.
If it persists you might be missing the Appcompat library, which you can install via nuget.

Xamarin.Android: Package XX is not compatible with monoandroid81 (MonoAndroid,Version=v8.1)

I encounter a stranger behavior with a Xamarin.Android project in Visual Studio on Windows.
I've created a new Android blank project, and I try ton install the NuGet package "AForge" (a mathematics library), but I get the following error message:
Package AForge 2.2.5 is not compatible with monoandroid81
(MonoAndroid,Version=v8.1).
I've already tried to re create several projects, after having relaunched Visual Studio and the computer, but the problem is still the same.
However, if I do the same thing on Mac, through Visual Studio for Mac, I don't encounter the same problem: the package is well installed.
In add, I can see in the package.config file, that the package il well related to monodroid81:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AForge" version="2.2.5" targetFramework="monoandroid81" />
</packages>
Would you have any explanation about this issue?
Update: new issue
Hi #Leo Liu-MSFT, I come back to you as I encounter an new issue. The dll copy works fine locally, but I get an error on AppCenter:
CoreCompile:
/Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/4.5/csc.exe
/noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4
/define:DEBUG;TRACE;XAMARIN_ANDROID_v1_0;MOBILE;ANDROID;ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4;ANDROID_5;ANDROID_6;ANDROID_7;ANDROID_8;ANDROID_9;ANDROID_10;ANDROID_11;ANDROID_12;ANDROID_13;ANDROID_14;ANDROID_15;ANDROID_16;ANDROID_17;ANDROID_18;ANDROID_19;ANDROID_20;ANDROID_21;ANDROID_22;ANDROID_23;ANDROID_24;ANDROID_25;ANDROID_26;ANDROID_27
/reference:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Java.Interop.dll
/reference:/Users/vsts/.nuget/packages/microsoft.appcenter.analytics/1.7.0/lib/MonoAndroid403/Microsoft.AppCenter.Analytics.Android.Bindings.dll
/reference:/Users/vsts/.nuget/packages/microsoft.appcenter.analytics/1.7.0/lib/MonoAndroid403/Microsoft.AppCenter.Analytics.dll
/reference:/Users/vsts/.nuget/packages/...
Services/AudioService.cs(8,7): error CS0246: The type or namespace
name 'AForge' could not be found (are you missing a using directive or
an assembly reference?)
[/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj] Done
Building Project
"/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj"
(PackageForAndroid target(s)) -- FAILED.
So I tried your suggestion, but I get an error when I try to save the package:
a local file header is corrupted'
Would you have another suggestion?
Would you have any explanation about this issue?
You can get the official document here:
Description: With PackageReference, assemblies present at the root of
lib folder without a target framework specific sub-folder are ignored.
NuGet looks for a sub-folder matching the target framework moniker
(TFM) corresponding to the project’s target framework and installs the
matching assemblies into the project.
In this case, NuGet will consider installing this package to the .NET Framework, which is not compatible with monoandroid81. Then you will that error "Package AForge 2.2.5 is not compatible with monoandroid81".
To resolve this issue, the best way is contact the author of the AForge NuGet package to update this package, or you can also add reference dll file directly to your project.
Besides, if you still want to use nuget to manager this package, I would like provide you a workaround to resolve this issue:
Download this nuget package from nuget.org.
Copy the download package, rename it with .zip, like aforge.2.2.5 - Copy.nupkg.zip, then unzip it.
Open the package aforge.2.2.5.nupkg with NuGet Package Explorer(Get it from Microsoft store), add a new folder MonoAndroid81 under the lib node, add exists file AForge.dll and AForge.xml from the copy folder aforge.2.2.5 - Copy.nupkg.zip, save this nuget package.
Add this new create nuget package to the nuget local feed, then add this nuget package to the project. Do not forget delete the nuget package cache in the C:\Users\<UserName>\.nuget\packages\aforge before you add the package.
Hope this helps.

NuGet package without assemblies complains about lack of assemblies

I'm creating a content-only NuGet package (e.g. no DLLs, just text files in this case). When I install the package, I get this error message:
Install-Package : Could not install package 'CodeGenerator.Templates.EF6-CQRS-Aurelia 1.0.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', 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.
This is all true, but I don't want to target any framework for this package -- how can I accomplish this?
The package is here: https://www.nuget.org/packages/CodeGenerator.Templates.EF6-CQRS-Aurelia
I had the same problem but with only a build target (and no assemblies).
Just adding an empty lib folder to my root package directory fixed it.
(Maybe a bug in NuGet. I have submitted an issue.)

Resources