dotnet pack "The element <package> is unrecognized" - dotnet-cli

Im trying to create a NuGet package of a dotnet new template. I created a nuspec file to set the details of the package, and it sits adjacent to my contents foler, which contains everything I want packaged up:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<!-- The identifier that must be unique within the hosting gallery -->
<id>My.EpiserverCMS</id>
<!-- The package version number that is used when resolving dependencies -->
<version>1.0.0</version>
<!-- Authors contain text that appears directly on the gallery -->
<authors>Me</authors>
<description></description>
<!--
Owners are typically nuget.org identities that allow gallery
users to easily find other packages by the same owners.
-->
<owners>me</owners>
<!-- License and project URLs provide links for the gallery -->
<licenseUrl></licenseUrl>
<projectUrl></projectUrl>
<!-- The icon is used in Visual Studio's package manager UI -->
<iconUrl></iconUrl>
<!--
If true, this value prompts the user to accept the license when
installing the package.
-->
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<!-- Any details about this particular release -->
<releaseNotes>First Release</releaseNotes>
<!--
The description can be used in package manager UI. Note that the
nuget.org gallery uses information you add in the portal.
-->
<description>dotnet new template for Episerver CMS</description>
<!-- Copyright information -->
<copyright>Copyright ©2018 Me</copyright>
<!-- Tags appear in the gallery and can be used for tag searches -->
<tags>web episerver cms</tags>
<!-- Dependencies are automatically installed when the package is installed -->
<dependencies>
</dependencies>
<packageTypes>
<packageType name="Template" />
</packageTypes>
</metadata>
<!-- A readme.txt to display when the package is installed -->
<files>
<file src="README.md" target="" />
<file src="**" exclude=".vs\*,packages\*,**\*.mdf,**\*.ldf,**\*.log"></file>
</files>
</package>
But when I run dotnet pack I get the error:
error MSB4068: The element <package> is unrecognized, or not supported in this context.
Which I really dont get. Isnt package supposed to be the root element in a .nuspec file?

dotnet pack doesn't support packing nuspec files. It only supports msbuild projects that contain a Pack target.
You can create a csproj project and use the NuspecFile property or use nuget pack through a nuget.exe version from http://nuget.org/downloads or through a nuget executable provided by the mono framework on non-windows platforms.

dotnet pack does support nuspec files. However, you have to pass them a couple specific configuration flags and add a dependency to your project. See the documentation here: https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#packing-using-a-nuspec

Related

Define variables in csproj SDK style

I have converted a WPF project to the new csproj SDK format. It shows some properties such as:
Company: $(Authors)
Where do I define the variable $(Authors) and similar such variables? I am building my project both locally and in Azure DevOps.
This is MSBuild specific, it does not depend on SDK project style in particular, see:
Define and reference properties in a project file
Define a tag with the name of the property inside a PropertyGroup.
<Project Sdk="Microsoft.NET.Sdk">
<!-- ... -->
<PropertyGroup>
<Authors>John Doe, Jane Doe</Authors>
</PropertyGroup>
<!-- ... -->
</Project>
Since you refer to a property named Authors, you probably mean a special property that is used for NuGet packaging, see pack target inputs and Package properties.

Load WPF assembly from console application

How can I load a WPF User Control Library dynamically from a console application?
Problem description:
I have an assembly that is compiled as WPF User Control Library and want to load it from a console application using reflection. Unfortunately, I receive a System.Reflection.ReflectionTypeLoadException with this message:
Unable to load one or more of the requested types. Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Loading "normal" Class Library assemblies works without problems. Even if they have dependencies, everything is loaded correctly. However, loading fails as soon as the assembly contains WPF.
What I tried:
I tried different ways to load the assembly, but all of them fail with above exception:
Using System.ComponentModel.Composition with imports and exports.
Using Assembly.LoadFrom().
Using a custom AssemblyLoadContext as described at learn.microsoft.com.
I made sure that the path to the assembly is correct. If I specify invalid paths, the error message is different.
Details:
The assembly has target framework .NET Core 3.1 and output type Class Library. It uses the Microsoft.NETCore.App and the Microsoft.WindowsDesktop.App.WPF frameworks.
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>
The console application has target framework .NET Core 3.1 and output type Console Application. It uses the Microsoft.NETCore.App framework.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

Android Manifest Map error in react native

I get this error when click listing in android devices.. attach listing error and sentry report.
if need update AndroidManifest.xml .. i found so many AndroidManifest.xml in my source.
https://user-images.githubusercontent.com/25501496/62419485-dcb8a380-b6b3-11e9-99bb-a0780134638d.jpeg
https://user-images.githubusercontent.com/25501496/62432060-fdd6ce00-b75f-11e9-81de-11519a131125.jpeg
i tried add code in android manifest file..but i check got too many files
im using template from codecanyon " Listapp "
You need to add your API key in your AndroidManifest.xml file (which is usually located in app\src\main), within the <application> element, like the error message indicates.
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>
Hope this helps.
in the meta-data tag, it must be:
<application>
<!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="Your Google maps API Key Here"/>
</application>

Add scala class to DataNucleus enhancer CLASSPATH

I am writing a Google App Engine web app and wish to use Scala on the server side. I'm using Eclipse and the Google App Engine plugin. However, as soon as I add an empty Scala class source file to my project, the DataNucleus enhancer warns:
SEVERE: Class "com.my.package.UserAccount" was not found in the
CLASSPATH. Please check your specification and your CLASSPATH.
I will eventually get round to making the class persistent but I want to get rid of this error first.
So far I've added the Scala Nature, and have tried cleaning the project and also restarting Eclipse but I always get the same warning issued from the enhancer.
Any ideas on what I can do to get the enhancer to run successfully?
I've struggled away with this for the last few days. Class not found errors thrown by the datanucleus enhancer on Scala classes occur because the scala-library.jar file isn't in the classpath when the enhancer runs. I've found two solutions:
Simple but cludgy: Copy scala-library.jar to the folder in eclipse/plugins which contains the enhancer. For me this is currently: /opt/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.5.5.r36v201110112027/appengine-java-sdk-1.5.5/lib/tools/orm
Switch off the enhancer builder in your project properties and create an ant file to run it manually. You can then properly control the classpath. I really struggled to get the scala-library into the classpath so gave up and copied it into the same folder as my datanucleus jars. My ant file if anyone's interested is:
<project name="DataNucleusEnhancer" default="enhance" basedir=".">
<property name="base.dir" location="/home/steve/Projects/DNProject"/>
<property name="datanucleus.libs" location="/home/steve/Projects/Jar Libraries/datanucleusjars"/>
<property name="sdk.dir" location="/opt/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.5.5.r36v201110112027/appengine-java-sdk-1.5.5"/>
<property name="classes.dir" location="${base.dir}/war/WEB-INF/classes/"/>
<property name="entities.dir" location="${base.dir}/war/WEB-INF/classes/packagenamehere/entities"/>
<path id="enhancer.classpath">
<fileset dir="${datanucleus.libs}" includes="*.jar" excludes="" />
<fileset dir="${sdk.dir}/lib/user" includes="*.jar" />
</path>
<target name="enhance" description="DataNucleus enhancement">
<taskdef name="datanucleusenhancer" classpathref="enhancer.classpath" classname="org.datanucleus.enhancer.tools.EnhancerTask" />
<datanucleusenhancer dir="${classes.dir}" failonerror="true" verbose="true">
<fileset dir="${entities.dir}" includes="**/*.class" />
<classpath>
<path location="${base.dir}/war/WEB-INF/classes/"/>
<path refid="enhancer.classpath"/>
</classpath>
</datanucleusenhancer>
</target>
</project>
In testing I also found the enhancer unwilling to enhance classes if I had no namespaces. I'm also concerned that I now need to manage the copy of scala-library.jar to make sure it's the same as in the scala eclipse plugin. It'd be much better if the gae plugin worked properly!
I tried the option 1 of steve's answer dropping the scala-library.jar in the eclipse plugin folder. It is still not solving yet. I then drop scala-library.jar in PROJECT/war/WEB-INF/lib/ and add it to Build Path. It works! So I undo option 1 of steve's answer by removing the scala-library.jar from the eclipse plugin folder and restart the eclipse. I try again and it still works! I am using eclipse 2.7.1, scala 2.9.1 and scala-ide 2.0.0

WPF Custom fonts problem

This is really weird. In Blend 4, the custom font works when I see the application in the designer, but when I run it, the font is gone and it goes back to arial or something. This is my XAML:
<TextBlock Text="Text G" FontFamily="/ProjectName;component/Fonts/#Futura Lt BT" FontSize="48" Background="#FFC44747" />
The font is in a folder called "Fonts" and the control in which I'm trying the font is in a folder called "Controls". I know it must be a problem with the relative position of the "Fonts" folder to the "Controls" folder, but I've already tried a lot of stuff and it doesn't work.
Also, the XAML markup I put up there is what Blend creates when I select the custom font. The font is copied as a resource all right (I already check the csprof file and it's there).
Any ideas? This has been kicking my butt for a couple hours now.
Thanks.
While I understand that this is far too late to help the question author, I am leaving this to help future viewers of this question.
The information in this answer comes from the Packaging Fonts with Applications page on MSDN:
Adding Fonts as Content Items
You can add fonts to your application as project content items that are separate from the application's assembly files. This means that content items are not embedded as resources within an assembly. The following project file example shows how to define content items.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Other project build settings ... -->
<ItemGroup>
<Content Include="Peric.ttf" />
<Content Include="Pericl.ttf" />
</ItemGroup>
</Project>
In order to ensure that the application can use the fonts at run time, the fonts must be accessible in the application's deployment directory. The element in the application's project file allows you to automatically copy the fonts to the application deployment directory during the build process. The following project file example shows how to copy fonts to the deployment directory.
<ItemGroup>
<Content Include="Peric.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Pericl.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Adding Fonts as Resource Items
You can add fonts to your application as project resource items that are embedded within the application's assembly files. Using a separate subdirectory for resources helps to organize the application's project files. The following project file example shows how to define fonts as resource items in a separate subdirectory.
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Other project build settings ... -->
<ItemGroup>
<Resource Include="resources\Peric.ttf" />
<Resource Include="resources\Pericl.ttf" />
</ItemGroup>
</Project>
When you add fonts as resources to your application, make sure you are setting the element, and not the element in your application's project file. The element for the build action is not supported.
The following markup example shows how to reference the application's font resources.
<TextBlock FontFamily="./resources/#Pericles Light">
Aegean Sea
</TextBlock>
Please follow the above link for details on referencing Font resources from code and other useful information.
Everywhere over the internet and in books it says that when you add a font you should set the Build Action to "Resource" (example here). And it 'worked for a while. Anyway, to fix my problem, I had to change it from "Resource" to "Content".

Resources