Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell NuGet:替换令牌';配置';在构建Visual Studio解决方案时没有任何价值_Powershell_Visual Studio 2013_Nuget_Nuget Package - Fatal编程技术网

Powershell NuGet:替换令牌';配置';在构建Visual Studio解决方案时没有任何价值

Powershell NuGet:替换令牌';配置';在构建Visual Studio解决方案时没有任何价值,powershell,visual-studio-2013,nuget,nuget-package,Powershell,Visual Studio 2013,Nuget,Nuget Package,我使用VS2013的NuGet Packager项目模板创建了一个NuGet包。我正在尝试将bin\CONFIGURATION文件夹中的DLL文件复制到Package.nuspec文件中使用的nupkg文件的lib文件夹中 在Visual Studio中构建解决方案时,我在NuGet.log中遇到以下错误: Package.nuspec的相关片段: 我可以使用此命令从命令行将其打包: c:\Path\To\Project> nuget pack -Properties Package.

我使用VS2013的NuGet Packager项目模板创建了一个NuGet包。我正在尝试将
bin\CONFIGURATION
文件夹中的DLL文件复制到Package.nuspec文件中使用的nupkg文件的
lib
文件夹中

在Visual Studio中构建解决方案时,我在NuGet.log中遇到以下错误:

Package.nuspec的相关片段:


我可以使用此命令从命令行将其打包:

c:\Path\To\Project> nuget pack -Properties Package.nuspec
因此,我在NuGetPackage.ps1中做了一些尝试,发现了以下部分:

# Create symbols package if any .pdb files are located in the lib folder
If ((Get-ChildItem *.pdb -Path .\lib -Recurse).Count -gt 0) {
    $packageTask = Create-Process .\NuGet.exe ("pack Package.nuspec -Symbol -Verbosity Detailed")
    $packageTask.Start() | Out-Null
    $packageTask.WaitForExit()

    $output = ($packageTask.StandardOutput.ReadToEnd() -Split '[\r\n]') |? {$_}
    $error = (($packageTask.StandardError.ReadToEnd() -Split '[\r\n]') |? {$_}) 
    Write-Log $output
    Write-Log $error Error

    $global:ExitCode = $packageTask.ExitCode
}
Else {
    $packageTask = Create-Process .\NuGet.exe ("pack Package.nuspec -Verbosity Detailed")
    $packageTask.Start() | Out-Null
    $packageTask.WaitForExit()

    $output = ($packageTask.StandardOutput.ReadToEnd() -Split '[\r\n]') |? {$_}
    $error = (($packageTask.StandardError.ReadToEnd() -Split '[\r\n]') |? {$_}) 
    Write-Log $output
    Write-Log $error Error

    $global:ExitCode = $packageTask.ExitCode
}
我看到了创建NuGet.exe命令的位置,因此将其修改为:

$packageTask = Create-Process .\NuGet.exe ("pack -Properties Package.nuspec -Verbosity Detailed")
然后我得到:

NuGet.CommandLineException:请指定要使用的nuspec或项目文件

我删除了文件路径的
$configuration$\
段,然后得到:

替换令牌“id”没有值


更新:我用NuGetPackage.ps1中我的项目的.csproj文件名替换了
Package.nuspec
,现在通过VisualStudio正确地创建了.nupkg文件。不过,我不希望对每个NuGet包都这样做



从Visual Studio而不是命令行进行构建时,如何在
Package.nuspec
中使用替换令牌?

我找到了一个解决方法。打包Visual Studio中的NuGet Packager项目模板中包含的项目的默认power shell脚本打包
.nuspec
文件。将其更改为我的项目的
.csproj
文件解决了这个问题,我必须在两个地方执行此操作:

# Create symbols package if any .pdb files are located in the lib folder
If ((Get-ChildItem *.pdb -Path .\lib -Recurse).Count -gt 0) {
    $packageTask = Create-Process .\NuGet.exe ("pack YourProject.csproj -Symbol -Verbosity Detailed")

    // ...
}
Else {
    $packageTask = Create-Process .\NuGet.exe ("pack YourProject.csproj -Verbosity Detailed")

    // ...
}
这不是100%的理想,因为NuGet Packager项目并不是开箱即用的,但这只是一个简单的更改


请注意,PowerShell构建脚本从
pack Package.nuspec
更改为
pack YourProject.csproj
,您可以将
YourProject.csproj
替换为NuGet Package项目的.csproj文件。

我找到了一个解决方法。打包Visual Studio中的NuGet Packager项目模板中包含的项目的默认power shell脚本打包
.nuspec
文件。将其更改为我的项目的
.csproj
文件解决了这个问题,我必须在两个地方执行此操作:

# Create symbols package if any .pdb files are located in the lib folder
If ((Get-ChildItem *.pdb -Path .\lib -Recurse).Count -gt 0) {
    $packageTask = Create-Process .\NuGet.exe ("pack YourProject.csproj -Symbol -Verbosity Detailed")

    // ...
}
Else {
    $packageTask = Create-Process .\NuGet.exe ("pack YourProject.csproj -Verbosity Detailed")

    // ...
}
这不是100%的理想,因为NuGet Packager项目并不是开箱即用的,但这只是一个简单的更改

请注意,PowerShell构建脚本从
pack Package.nuspec
更改为
pack YourProject.csproj
,其中您将用NuGet Package项目的.csproj文件替换
YourProject.csproj