简体   繁体   English

保持packages.config和nuspec同步

[英]Keeping packages.config and nuspec in sync

I've been resorting to manually modifying my .nuspec files every time I update packages. 每次更新软件包时,我一直在手动修改.nuspec文件。 Is there an automatic way of doing this? 有自动的方法吗? I'd rather not have to create an additional build step that compares both files and syncs them. 我宁愿不必创建一个比较两个文件并同步它们的附加构建步骤。

I believe MyGet does this OOB, but unfortunately I can't use MyGet for this specific package. 我相信MyGet会执行此OOB,但是不幸的是,我无法将MyGet用于此特定程序包。

(FWIW, I'm using VS2015 and Xamarin Studio) (FWIW,我正在使用VS2015和Xamarin Studio)

Just call the nuget pack against the csproj instead of nuspec , for example: 只需针对csproj而不是nuspec调用nuget pack ,例如:

nuget pack X.csproj

In addition, you'll have to remove the dependencies from the nuspec , otherwise nuget will get it from there instead of from packages.config . 另外,您必须从nuspec删除依赖nuspec ,否则nuget将从那里获取依赖关系,而不是从packages.config

BTW, check the created nupkg . 顺便说一句,检查创建的nupkg It may have unwanted files added to it, like, for instance, txt files, if you happen to have any in your project. 如果您的项目中碰巧有多余的文件,例如txt文件,它可能会添加到其中。

If that's the case, you'll have to invoke nuget pack with the -Exclude parameter: 如果是这种情况,则必须使用-Exclude参数调用nuget pack

nuget pack X.csproj -Exclude **.txt

I ended up creating a quick C# script (LINQPad rules) that syncs .config and .nuspec using XDocument, NuGet.Core and LINQ. 我最终创建了一个快速的C#脚本(LINQPad规则),该脚本使用XDocument,NuGet.Core和LINQ同步.config和.nuspec。 If anyone's interested, I'll post it as a gist. 如果有人感兴趣,我将其作为要点发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM