创建NuGet
2017-11-17 12:23 多多多多多奈特 阅读(203) 评论(0) 收藏 举报1.新建项目(类库)
2.写好测试方法
public static string FormateDate(DateTime mDateTime, string separator) { return mDateTime.Year.ToString("0000") + separator + mDateTime.Month.ToString("00") + separator + mDateTime.Day.ToString("00"); } /// <summary> /// 将分钟数转为字符的时间格式: 60 --> 01:00 /// </summary> /// <param name="intMins"></param> /// <returns></returns> public static string ConvertMinsToFormatTime(int intMins) { string result = "00:00"; //string.Empty ; if (intMins < 1) { return result; } string minsToHrs = (intMins / 60).ToString(); string mins = (intMins % 60).ToString(); result = FillZeroBefore(minsToHrs, 2) + ":" + FillZeroBefore(mins, 2); return result; } /// <summary> /// 将字符的时间格式转为分钟数: 01:00 --> 60 /// </summary> /// <param name="strInput"></param> /// <returns></returns> public static int ConvertFormatTimeToMins(string strInput) { int result = 0; if (strInput.Length < 1) { return result; } int mins = 0; int hrsToMins = 0; string[] arr = strInput.Split(new char[1] { ':' }); if (arr.Length == 1) { int.TryParse(arr[0], out mins); } else if (arr.Length > 1) { int.TryParse(arr[0], out hrsToMins); int.TryParse(arr[1], out mins); } result = mins + hrsToMins * 60; return result; } private static string FillZeroBefore(string strInput, int intStringLen) { string strReturn = strInput; if (strInput.Length > 0 && strInput.Length < intStringLen) { int fillCount = intStringLen - strInput.Length; for (int i = 0; i < fillCount; i++) { strReturn = "0" + strReturn; } } return strReturn; }
3.填写版本信息 -->AssemblyInfo.cs (可填可不填)
4.生成项目
5.下载NuGet.exe (地址 http://nuget.codeplex.com/downloads/get/669083)
6.注册nuget 并且生成key (地址 www.nuget.org)
注册成功后,选择用户菜单下的api keys 并创建 ,成功后拷贝key 保存起来用来生成包
7.将下好的NuGet.exe 放到项目路径 (同bin一个目录)
8.用开发人员命令 打开到项目路径(同bin一个目录)
9.设置key 命令:nuget setApiKey xxxxxxxx-xxxxxxx-xxxxxxxx
10.生成.nuspec文件 命令:nuget spec
11.修改.nuspec文件 (版本信息, 描述等)
12.生成包文件.nupkg 命令: Nuget pack 项目.csproj
13.登陆nuget.org 上传包 即.nupkg文件(提交上传后 需要等一段时间 貌似网站需要给包加索引 也就几分钟)
14.vs中 工具--->NuGet包管理 --> 管理解决方案的NuGet包 -->联机 搜索你的包 (.nuspec 文件中 id即识别码 titile都可以 网站中也能看到) 前提网站已添加你包的索引不然搜不到
15.添加包后会选择项目 添加dll 添加成功就可以开始用了

浙公网安备 33010602011771号