C# 如何在构建期间使用nuget包?

C# 如何在构建期间使用nuget包?,c#,.net,msbuild,visual-studio-2015,nuget,C#,.net,Msbuild,Visual Studio 2015,Nuget,我想在构建过程中使用一些使用nuget获得的工具。以下是csproj文件的相关部分: <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'"> <GetAssemblyIdentity AssemblyFiles="$(TargetPath)"> <Output TaskParameter="Assemblies" ItemName="myAssemblyI

我想在构建过程中使用一些使用nuget获得的工具。以下是
csproj
文件的相关部分:

<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
    <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
        <Output TaskParameter="Assemblies" ItemName="myAssemblyInfo"/>
    </GetAssemblyIdentity>
    <Exec Command="nuget pack MyApp.nuspec -Version %(myAssemblyInfo.Version) -Properties Configuration=Release -OutputDirectory bin\Release -BasePath bin\Release" />
    <Exec Command="squirrel --no-msi --releasify bin\Release\MyApp.%(myAssemblyInfo.Version).nupkg" />
</Target>


也就是说,我想使用
Squirrel
NuGet
本身(包含在
NuGet.CommandLine
包中)来构建安装程序。可执行文件位于
包\\tools\*.exe
中。
Exec
命令中使用的行在PackageManager控制台中工作,但Visual Studio在生成过程中找不到可执行文件(错误9009)。在构建过程中,是否有办法在当前路径中包含包工具以使其可用?

这是Windows应用商店应用程序还是标准的WPF/Winforms/Console应用程序?这确实有区别。在构建之前,您是否尝试过nuget包还原?Visual Studio会自动执行此操作,但使用MSBuild这是一个额外的步骤。我是从Visual Studio生成的。它已经拥有最新版本的所有软件包,并且VS已启用自动还原。有时,当我打开Package Manager控制台(不键入任何内容)时,它以某种方式加载工具路径,我可以成功构建,但有时它不起作用。我认为
squirrel
是一个powershell脚本,这意味着您需要使用
powershell-Command{squirrel--no-msi--releasify…}调用它