Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.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
C# 将nuget包内容文件(类型为.exe)复制到使用该nuget包的项目的输出目录_C#_Visual Studio_Nuget_Nuget Package_Nuget Server - Fatal编程技术网

C# 将nuget包内容文件(类型为.exe)复制到使用该nuget包的项目的输出目录

C# 将nuget包内容文件(类型为.exe)复制到使用该nuget包的项目的输出目录,c#,visual-studio,nuget,nuget-package,nuget-server,C#,Visual Studio,Nuget,Nuget Package,Nuget Server,我有一个项目,其中有一些exe作为“依赖项”,我从.csproj文件中以nuget包的形式构建该项目 文件如下所示: <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netstandard2.0</TargetFramework> <Nullable>enable</Nullable> &l

我有一个项目,其中有一些exe作为“依赖项”,我从
.csproj
文件中以nuget包的形式构建该项目

文件如下所示:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <Nullable>enable</Nullable>
    <LangVersion>latest</LangVersion>
    <Version>1.1.2</Version>
    <PackageId>MyLib</PackageId>
    <Authors>me</Authors>
    <Company>me</Company>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="CliInterface\32BitInterface.exe" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="CliInterface\32BitInterface.exe">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
      <PrivateAssets>analyzers;build</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

netstandard2.0
使可能
最新的
1.1.2
迈里布

但是,它不会复制到输出文件夹。 事实上,正确地说,这是当我从
visualstudio
运行
Build
项目时,但我在
CI/CD
环境中使用
dotnet Build
命令,并且在运行该命令时不会将其复制到输出

编辑: 我还注意到那个exe的位置在%USERPROFILE%.nuget文件夹中
另外,我的csproj文件(来自另一个解决方案,它引用了nuget包)有一个硬编码路径,其中包含我的用户名。我不知道为什么会这样,但我不喜欢这样,相反,试着用这个

true

将这些添加到
csproj
文件中:

<ItemGroup>
    <Content Include="CliInterface\32BitInterface.exe">
     <PackageCopyToOutput>true</PackageCopyToOutput>
    </Content>
 </ItemGroup>

真的
然后重新打包lib项目。尝试安装此新版本时,请不要忘记删除或删除
C:\Users\xxx(当前用户)\.nuget\packages
下的缓存文件


除了,这也是。

您可以尝试此操作。您可以尝试移除零件吗?这应该是默认选项。释放不在输出文件夹中的内容文件有什么意义。和tnx:)
PackageCopyToOutput
用于将nuget软件包中的内容文件复制到主项目的输出文件夹中,而
copytooutdirectory
用于将主项目的内部文件复制到输出文件夹中。