(이게 없으면, nuget.exe파일에 대한 명시적 실행 파일 실행 경로를 설정해 줘야함..)
2. 솔루션 준비
Package를 생성 할 솔루션을 만든다.
1 #pragma once
2
3 #include
<iostream>
4 #include
<stdio.h>
5
6 class
SampleNativePackageApp
7 {
8 public:
9 void ShowMessage() { std::cout << "SampleNativePackage
Version 1" << std::endl; }
10};
3. Nuget.org ApiKey 받기
패키지 파일을 배포하기 위해서는 Api 키가 필요하다.
https://www.nuget.org/ 에 가입 후
자신의 계정으로 들어간다.
그림과 같이 ApiKeys 항목에서 발급이 가능하다.
4. Package 파일 만들기(Create Package)
- 먼저 패키지를 만들기 위해서는 package에 대한 설명과 프로젝트의 설정 정보가 필요하다. 이를 포함하는것이 .autopkg 라는 파일이다.
누겟 홈페이지에 가면, .nuspec 이라는 파일을 만들어야 한다고 한다. 그런데 아래의 문장을 보면,
.nuspec 파일은 .Net 기반의 파일을 의미한다고 추정한다.( autopkg 파일 역시 비슷한 파일이므로…)
어쨌든, c++에서 package를 만들기 위해서는 .autopkg 파일을 만들어 보자.
형식은 아래와 같으며. 각 항목에 맞게 끔 잘 정리 해 주자.
모든 과정을 설명할 수 없기 때문에, 자세한 내용은 생략하고 이 역시도 coApp-Packages라는 script 문법이 있는것 같다.
nuget {
nuspec {
id = HelloWorldNuGetTemplate;
version : 0.0.0.1;
title: HelloWorldNuGetTemplate Lib By
Devman;
authors: {Devman};
owners: {Devman};
requireLicenseAcceptance:false;
summary:Template NuGet Native Package;
description: @"This is a
Devman";
releaseNotes: "Last Release";
copyright: Copyright (c) 2017 DevMan
Corporation. All rights reserved.;
tags: { sample, native, c++ };
};
files {
include: { NuGetTemplate.h };
// The release here works for any config
that contains release
// Examples : Release ENU, RELEASE-ENU,
Release DEU
[release] {
lib: { Release\*.lib; }
};
// The debug here works for any config
that contains debug
// Examples : Debug ENU, DEBUG-ENU,
Debug DEU
[debug] {
lib: { Debug\*.lib; }
symbols: { Debug\*.pdb; }
};
};
}
** 주의 사항으로, Id/version은 반드시 수정하도록 하자. 특히 id 경우 샘플이름으로 사용할 경우, upload시 중복된 이름의 package fail 이 발생하기 때문이다. **
HelloWorldNuGetTemplate.autopkg 라는
파일을 생성하고, 이를 솔루션 파일과 동일한 위치에 두자.
Tools > NuGet Package Manager >
Package Manager Console 를 실행한다.
아래와 같은 실행 화면이 나오면 Write-NuGetPacakage
*.autopkg 입력한다.
*.nupkg 파일이 성공적으로 생성된것을 확인 할 수 있다.
(위 그림에서 nupkg 파일이 두개 생성되었는데, 이는 autopkg 파일에 빌드 옵션 때문에 그런것이다. 1개만 생성되면 된다.)
위와 같은 방법으로 패키지 파일을 생성할 수 있다.
다음번에는 배포(Publish) 하는 방법에 대해서 알아 보겠다.
참고
- http://blog.naver.com/PostView.nhn?blogId=drvoss&logNo=20207977957
- http://debop.blogspot.kr/2012/03/nuget.html
- https://blogs.techsmith.com/inside-techsmith/nuget-packages-3/
- http://www.codeguru.com/csharp/article.php/c19247/Creating-Your-Own-NuGet-Package.htm
- https://blogs.msdn.microsoft.com/vcblog/2013/06/18/deep-dive-into-nuget-native-part-one/
- http://coapp.org/tutorials/building-a-package.html