I want to publish package about sdl_mixer, it's a native package. I did as tutorial said. I put .dll .hand .lib files into package content, but the final package didn't work. So what is right way to create c++ nuget package?
Another question: I found in nuget, most native c++ package are published in two packages, for example:
sdl2_ttf.v140
sdl2_ttf.v140.redist
What is difference between those two files? And how can I publish my packages like that?
Update:
I followed the tutorial on how to publish native packages. I have written the following autopkg file
nuget{
nuspec {
id = MySdl_mixer;
version :2.0.0.0;
title: sdl mixer;
authors: { Sam Lantinga, Stephane Peter, Ryan Gordon};
owners: {spartawhy117};
licenseUrl: "http://libsdl.org/license.php";
projectUrl: "http://libsdl.org/index.php";
iconUrl:"";
requireLicenseAcceptance:false;
summary:Nothing;
description: #"SDL_mixer is a sample multi-channel audio mixer library....
";
releaseNotes: "Release of C++ ";
copyright:Copyright 2015;
tags: {v140 ,sdl_mixer , native, CoApp };
};
files {
#defines {
Include = include\;
Bin = bin64\;
Lib = lib64\;
}
include:{"${Include}*"};
[x64,v140,debug,desktop]{
lib: ${Lib}SDL2_mixer.lib;
bin: ${Bin}SDL2_mixer.dll;
}
[x64,v140,release,desktop]{
lib: ${Lib}SDL2_mixer.lib;
bin: ${Bin}SDL2_mixer.dll;
}
};
targets {
Defines += HAS_SDLMIXER;
};
}
Running the command Write-NuGetPackage .\sdl_mixer.autopkg returns an error unexpected input of the end. What is the problem here?
I searched around for days until I found there is really no help out there on the internet at all. I did managed to piece together how to do it, and through trial and error got it working well. Which I have documented here:
https://digitalhouseblog.wordpress.com/2019/08/22/how-to-make-a-nuget-package-for-c/
But I'll summarize here anyways:
Gather or stage your native library files into a folder of your
choosing.
Create a *.nuspec file in that folder.
Edit the *.nuspec file to include the files you want to include in your package.
Create a *.props file
Call nuget pack to create the package.
Push the nuget package to a feed somewhere.
Create a packages.config file.
Edit the visual studio project file to import the *.props file
Notice that the nuget tools inside the visual studio IDE are NEVER used. You have to do a LOT manually. See the link for full details and explanations.
You can use CoApp PowerShell tools to create the Native Nuget packages easily.
Creating Native Packages
If you’re interested in publishing your
native libraries via NuGet, you can choose to create the NuGet
packages manually. However, there’s an easier way--the CoApp project
volunteered to write C++ oriented tools to create NuGet packages, and
they have released a beta version of their tools. These tools simplify
the process of generating the MSBuild files and NuGet packages from
existing header and library files--you just need to create a
configuration script to describe the contents of the package and then
run the tools to generate the NuGet package.
Refer to this link for more detailed information: Support for Native Projects.
If you want to do this from Visual Studio C++ using a Visual Studio Solution and projects.
Look at my answer here.
Create Nuget package for C++/C Visual Studio Solution projects
The above question seems to be Linux.
Related
I'm really new to programming, but I felt like trying out some bot-development for my discord server, like one that will occasionally say hello to people when they join, however when I tried to install one of the Discord packages I got this error
Unable to resolve dependency 'Microsoft.Extensions.DependencyInjection'. Source(s) used: 'discord.net', 'Microsoft Visual Studio Offline Packages'.
Unable to resolve dependency
'Microsoft.Extensions.DependencyInjection'. Source(s) used:
'discord.net', 'Microsoft Visual Studio Offline Packages'.
This error message always occurs when you want to install the package whose dependency package is not found. For example, I created a custom package(MyCustomPKG) that depends on Microsoft.Extensions.DependencyInjection.
And now I'll get the same issue if nuget can't find the Microsoft.Extensions.DependencyInjection in all available package sources.
To resolve that issue:
Add nuget.org(https://api.nuget.org/v3/index.json) as package sources and make sure the checkbox is enabled.
In addition: If you're not using VS IDE, instead you're using Nuget.exe+Nuget.config file, add this line(<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />) to Nuget.config.
I create a new Net Standard library, and I would like to publish the package to a local nuget repository.
In order to achieve it, I have two ways: using the command line, or using the publish option offered by Visual Studio.
Using the command line I use the "add" keyword from the command line (due to the fact it is a non-http package source), and it works fine, it create the nuget package with its nuget.sha512 file.
Using the publish option offered by Visual Studio, I've not been able to replicate the previous behavior, because it replicate the "push" keyword in the command line.
In the same local repository I can't hold two different packages, one with .nupkg.sha512 file and the other without it, because the nuget package manager will find only these packages without the ".nupkg.sha512" extension.
Is there any way I could tell to Visual Studio to replicate the "add" behavior using the publish option?
Thanks in advance.
Is there any way I could tell to Visual Studio to replicate the "add" behavior using the publish option?
I am afraid there is no such directly way that you could tell to Visual Studio to replicate the "add" behavior using the publish option, because the add command is only supported by NuGet CLI. We could not use it directly with publish option.
As workaround, you can add custom target to call NuGet CLI when you publish your project.
To accomplish this, edit your project. Then at the very end of the project, just before the end-tag </project>, place below scripts:
<Target Name="AddPackage" AfterTargets="GenerateNuspec">
<Message Text="Add Package to the local nuget repository!"></Message>
<Exec Command="<PathOfNuGetCli>\nuget.exe add "<PathOfPackage>\xxx.1.0.0.nupkg" -source "<localNuGetRepository>""></Exec>
</Target>
Note: Since this custom target depends on the target GenerateNuspec, it will be executed twice, but not worry about it, it will not have any actual operation when it is executed in the first time(The package has not yet been published to the specify folder).
Hope this helps.
We have downloaded a project from TFS and after restoring Nuget packages we are getting below error:
Error 5 The "ValidatePackageReferences" task could not be loaded from the assembly projectPath\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.Tasks.dll. Could not load file or assembly 'file:///projectPath\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. projectName
We have not used Task anywhere. It seems it is being used internally. Any pointer how to get rid of this error?
Mostly it looks like its because of wrong version of NuGet package. But not sure whats root cause.
We are using VS 2013 Update 5 version.
First search "Microsoft.Bcl.Build.Tasks.dll." nuget on google. Then a link will be opened with named "https://www.nuget.org/packages/Microsoft.Bcl.Build/". Then copy the package name shown on the site like this
Install-Package Microsoft.Bcl.Build -Version 1.0.21
Then Open the Visual studio , Goto Tools>Nuget Package Manager>Package manager console. Now paste the copied install package,Install it. Then restart the VS.Issue will be solved.
I am trying to learn to print using GDI.
I have searched MSDN for resources and found this example.
I like the thought of putting printing in separate thread, and using GDI is easier for me to learn than using XPS API so I have downloaded the example.
After trying to compile it ( I use Visual Studio 2008 ) I get this error:
fatal error C1083: Cannot open include file: 't2embapi.h': No such file or directory
According to this, I have found out that I am not the only one facing this problem.
Still, I have tried to Google the above error and found this that indicates me not having the latest SDK.
I have searched in C:\Program Files\Microsoft SDKs\Windows and found a folder v6.0A which indicates that I do not have latest SDK installed.
However, here I have found one post where person with the same problem did not solve it by downloading the latest SDK ( although the year that post was made is 2006, still the file was missing then too, and downloading the SDK didn't help-why should anything change now? ).
My question is:
Is there a way to get this file ( if I am wrong about downloading the latest SDK please correct me ) ?
I think that this file has to do something with fonts-is there a way to modify the example so I do not have to use that file?
Thank you for you rime to view this thread and for trying to help.
Best regards.
T2Embapi.h is supplied by the Windows SDK, it contains declarations for the Font Embedding Services Library to handle embedded OpenType fonts. Clearly the SDK version you use is too old to have it. Not exactly sure which version is required, I know that v6.0 doesn't have it but v7.1 does.
There's some sloppiness in the project due to it starting as an XPS sample. T2Embapi isn't actually required to build the GDI sample. You can simply delete the #include from stdafx.h. Also some sloppiness in the Release configuration settings of the project, remove T2embed.lib and XpsPrint.lib from the linker's Additional Dependencies setting.
Your question is:
1.
Is there a way to get this file ( if I am wrong about downloading the latest SDK please correct me ) ?
The latest version of Windows SDK is for Windows 8.1. Windows Software Development Kit (SDK) for Windows 8.1. However, I think the 't2embapi.h' have already included Windows SDK for Windows 7, because I found the header file in 'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include'.
2.
I think that this file has to do something with fonts-is there a way to modify the example so I do not have to use that file?
#Hans Passant has already answered about that.
I've a .NET Solution with a managed C++ assemlby Targeting .NET 3.5 created with VS2010. The command:
%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe MyProject.sln
compiles the solution on my dev machine.
On my BuildServer I get this error:
Build FAILED.
"F:\CruiseControl.NET\Projects\MyProject\MyProject.sln"
(default target) (1) ->
"F:\CruiseControl.NET\Projects\MyProject\MyProject\MyProject.csproj"
(default target) (2) ->
"F:\CruiseControl.NET\Projects\MyProject\MyProjectMAPIHelper\MyProjectMAPIHelper.vcxproj"
(default target) (3) ->
F:\CruiseControl.NET\Projects\MyProject\MyProjectMAPIHelper\MyProjectMAPIHelper.vcxproj(23,3):
error MSB4019: The imported project
"C:\Program
Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.Default.props"
was not found. Confirm that the path
in the <Import> declaration is
correct, and that the file exists on
disk.
0 Warning(s)
1 Error(s)
On my dev machine the claimed file
"C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.Default.props"
exists. On my build server not.
When I try to copy this files (and all others in the same directory) other errors occurred. So this is the wrong way.
EDIT: other errors means: When I copy the file "Microsoft.Cpp.Default.props" on the build server, MSBuild is claiming other files. That shows me, that just doing a copy of missing files is not what the build environment is expecting. I am looking for an MSI/whatever package that I could install on my build server and any C++ Project will build. Installing the SDK did not the trick. Or I did something wrong during SDK installation. Or it is not possible to compile Managed C++ VS2010 Solutions just with the SDK.
I believe that "other errors" has nothing to do with my problem. My Problem is: "How do I setup my build environment correctly". /EDIT
What I've done till now:
I have installed the latest Win7 SDK (Link)
I am targeting .net 3.5
I've tried playing with the Platform Toolset Property - but it was just playing
In my solution there is a managed C++ Assembly (my Problem)
I am using MSBuild 4.0 because the new VS2010 project files cannot be compiled with MSBuild 3.5
I am using CC.NET. compilation fails in CC.NET and on the command line. So it should not be a CC.NET issue.
Are there any tips and tricks how to configure my project properly to compile on my dev machine with VS2010 and on my build server? Is there anything more to install (except VS2010)?
Thanks, Arthur
For now, installing VS 2010 is your only safe option. The Windows SDK will be updated to enable your scenario, but I don't have a specific release date. Until then, you'll need to install VS 2010 with the C++ tools in order to build your 2010 solution with C++ projects. Make sure you let the C++ team know about how dissatisfaction with this situation via their team blog and/or MSDN Forum.
Even after installing VS 2010, you may need to invoke the appropriate vcvars*.bat file to setup your environment variables correctly.
Why don't you want to install VS2010 on your build server? If it's licencing, it's licenced per developer head not per install so I'm reasonably sure you are allowed to without buying another copy - or, at worst, you can install the express version which ought to at least install the config bits you're missing so you can use the platform SDK compiler.
If you're still having problems with msbuild you can then use devenv.com /build which exactly replicate the VS build env.
You may try those links:
http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/9055ca52-586b-459f-9dd1-a9d052d076b9/
or
http://msdn.microsoft.com/en-us/library/ee662426.aspx