如何为本机C ++创建nuget包 [英] How to create nuget package for native C++
问题描述
我想发布有关sdl_mixer的软件包,它是本机软件包.我按照教程的说明进行了操作.我将 .dll
.h
和 .lib
文件放入 打包内容 ,但是最终包装没有用.那么创建c ++ nuget包的正确方法是什么?
I want to publish package about sdl_mixer, it's a native package. I did as tutorial said. I put .dll
.h
and .lib
files into package content, but the final package didn't work. So what is right way to create c++ nuget package?
另一个问题:我在nuget中发现,大多数本机c ++软件包都发布在两个软件包中,例如:
Another question: I found in nuget, most native c++ package are published in two packages, for example:
sdl2_ttf.v140
sdl2_ttf.v140
sdl2_ttf.v140.redist
sdl2_ttf.v140.redist
这两个文件有什么区别?以及我该如何发布我的软件包?
What is difference between those two files? And how can I publish my packages like that?
更新:
我按照教程进行了发布本机软件包.我写了以下 autopkg文件
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;
};
}
运行命令 Write-NuGetPackage.\ sdl_mixer.autopkg
返回错误的末尾错误输入.这是什么问题?
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:
- 将本机库文件收集或暂存到您的文件夹中选择.
- 在该文件夹中创建一个* .nuspec文件.
- 编辑* .nuspec文件以包含要包含在软件包中的文件.
- 创建一个* .props文件
- 调用nuget pack创建包.
- 将nuget包推送到某处的feed中.
- 创建一个packages.config文件.
- 编辑Visual Studio项目文件以导入* .props文件
请注意,从未使用Visual Studio IDE中的nuget工具.您必须手动执行很多.有关完整的详细信息和说明,请参见链接.
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.
这篇关于如何为本机C ++创建nuget包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!