Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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 在类库(.NET标准)项目中添加install.ps1_Powershell_Nuget_Visual Studio 2017 - Fatal编程技术网

Powershell 在类库(.NET标准)项目中添加install.ps1

Powershell 在类库(.NET标准)项目中添加install.ps1,powershell,nuget,visual-studio-2017,Powershell,Nuget,Visual Studio 2017,我已将.NET Framework项目迁移到.NET标准项目 在.NET Framework项目中,我有一个带有附加文件配置的.nuspec文件,并使用nuget.exe包创建nuget包 <files> <file src="Install.ps1" target="tools\Install.ps1" /> </files 在.NET标准项目中,我不再有nuspec文件,而是切换到msbuild-t:Pack来创建nuget包。我已尝试将in

我已将.NET Framework项目迁移到.NET标准项目

在.NET Framework项目中,我有一个带有附加文件配置的.nuspec文件,并使用nuget.exe包创建nuget包

  <files>
     <file src="Install.ps1" target="tools\Install.ps1" />
  </files
在.NET标准项目中,我不再有nuspec文件,而是切换到msbuild-t:Pack来创建nuget包。我已尝试将install.ps1设置为BuildAction=Content,但随后在日志问题中看到一条警告:PowerShell file out side tools文件夹。在nupkg文件中,目录是content\tools\Install.ps1我需要tools\Install.ps1

我已尝试将install.ps1设置为BuildAction=Content,但随后在日志问题中看到一条警告:PowerShell file out side tools文件夹。在nupkg文件中,目录是content\tools\Install.ps1我需要tools\Install.ps1

使用msbuild-t:Pack创建nuget包时,msbuild/VS希望文件位于content文件夹中。但是,如果仍要在tools目录中安装.ps1文件,则仍可以使用.nuspec文件和nuget.exe来打包包

打包软件包的详细步骤:

按照以下设置创建.nuspec:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>TestInstall.ps1</id>
    <version>1.0.0</version>
    <authors>Test</authors>
    <owners>Test</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2017</copyright>
    <tags>Tag1 Tag2</tags>
  </metadata>

  <files>
    <file src="Install.ps1" target="tools" />
    <file src="bin\Debug\netstandard1.4\TestInstall.ps1.dll" target="lib\netstandard1.4" />
  </files>

</package>
然后使用命令行:nuget.exe pack xxx.nuspec打包软件包,您将在工具目录中获得包含Install.ps1的软件包:


要将文件放入包中的其他路径,可以使用元素中的元素,如下所示:

<ItemGroup>
    <Content Include="install.ps1">
        <PackagePath>tools\</PackagePath>
  </Content>
</ItemGroup>
如果install.ps1位于项目的根目录中,则必须调整Include属性值

有关更多信息,请在此处查看有关pack MsBuild目标的文档:


这个问题有更新吗?你们能从答案中得到有用的信息吗?如果没有,请让我知道此问题的最新状态。抱歉,没有更新,我的临时解决方案是在创建后使用添加工具文件夹7zip@Leo-MSFT不确定您是否会在添加新答案时收到通知,但我添加了一个适合我的解决方案,似乎是解决此问题的方法您对此问题有新的更新吗?