如何在 Cake Build Tool 中使用 Nuget 包
How To Use Nuget Packages in Cake Build Tool
build.cake:
var target = Argument("target", "Default");
Task("Default")
.Does(() => {
var client = new RestSharp.RestClient("www.test.com");
Information("Hello World!");
});
RunTarget(target);
packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.21.1" />
<package id="RestSharp" version="105.2.3" />
</packages>
收到错误:
error CS0246: The type or namespace name 'RestSharp' could not be fou
nd (are you missing a using directive or an assembly reference?)
使用 #addin
预处理器指令从 nuget 加载程序集,它将获取包并引用其中的程序集。
#addin nuget:?package=Cake.Foo
#addin nuget:?package=Cake.Foo&version=1.2.3
#addin nuget:?package=Cake.Foo&prerelease
#addin nuget:https://myget.org/f/Cake/?package=Cake.Foo&prerelease
您在 cakebuild.net 阅读了有关预处理器指令的更多信息。
您的示例脚本如下所示:
#addin nuget:?package=RestSharp&version=105.2.3
var target = Argument("target", "Default");
Task("Default")
.Does(() => {
var client = new RestSharp.RestClient("http://www.test.com");
Information("Hello World!");
});
RunTarget(target);
build.cake:
var target = Argument("target", "Default");
Task("Default")
.Does(() => {
var client = new RestSharp.RestClient("www.test.com");
Information("Hello World!");
});
RunTarget(target);
packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.21.1" />
<package id="RestSharp" version="105.2.3" />
</packages>
收到错误:
error CS0246: The type or namespace name 'RestSharp' could not be fou nd (are you missing a using directive or an assembly reference?)
使用 #addin
预处理器指令从 nuget 加载程序集,它将获取包并引用其中的程序集。
#addin nuget:?package=Cake.Foo
#addin nuget:?package=Cake.Foo&version=1.2.3
#addin nuget:?package=Cake.Foo&prerelease
#addin nuget:https://myget.org/f/Cake/?package=Cake.Foo&prerelease
您在 cakebuild.net 阅读了有关预处理器指令的更多信息。
您的示例脚本如下所示:
#addin nuget:?package=RestSharp&version=105.2.3
var target = Argument("target", "Default");
Task("Default")
.Does(() => {
var client = new RestSharp.RestClient("http://www.test.com");
Information("Hello World!");
});
RunTarget(target);