0

我正在尝试编译一个 .net 核心应用程序并转换为本机应用程序。我正在尝试将输出文件复制到 nuget 包。

我看到以下错误

NU5128:在 nuspec 的依赖项组和 lib/ref 文件夹中声明的某些目标框架在其他位置没有完全匹配。请参阅以下操作列表:

构建此项目的命令

rem Initialize the developer environment just like a developer box. Note that 'call' keyword that ensures that the script does not exist after 
rem calling the other batch file.
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64 
 
rem Save working directory so that we can restore it back after building everything. This will make developers happy and then 
rem switch to the folder this script resides in. Don't assume absolute paths because on the build host and on the dev host the locations may be different.
pushd "%~dp0"


dotnet build "%~dp0src\WindowsAuditSetting\SetACLNative.csproj" -c Release

rem Save exit code for dotnet restore.
set EX=%ERRORLEVEL%

rem Check exit code and exit with non-zero exit code so that build will fail.
if "%EX%" neq "0" (
    popd
    echo "Failed to build .NET Core sample correctly."
    exit /b %EX%
)

dotnet publish "%~dp0src\WindowsAuditSetting\SetACLNative.csproj" -c Release --no-restore 命令我跑来打包这个

nuget pack -Properties Configuration=Release

我的 nuspec 文件

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>ASMDevops</authors>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <license type="expression">MIT</license>
    <description>$description$</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>$copyright$</copyright>    
  </metadata>
</package>

我的 csproj 文件

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <runtimeidentifier>win-x64</runtimeidentifier> 
    <!-- <GeneratePackageOnBuild>true</GeneratePackageOnBuild> -->
  </PropertyGroup>
  
  <ItemGroup>
    <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-29408-02" />
    <PackageReference Include="Microsoft.Win32.Registry" Version="4.4.0" />
  </ItemGroup>


  <PropertyGroup>
    <PackageId>AsmScannersUtilities</PackageId>
    <Version>1.0.0</Version>
    <Authors>ASMDevops</Authors>
    <Company>your_company</Company>
    <Description>Client side scanning from Azure Security Monitoring. This package is consumed by AzSecPack</Description>
  </PropertyGroup>

  <Target Name="CopyPackage" AfterTargets="Publish">
    <Copy SourceFiles="$(OutputPath)publish\SetACLNative.exe"  DestinationFolder="$(OutputPath)..\..\AsmScanners" />
    <Copy SourceFiles="$(OutputPath)publish\SetACLNative.deps.json"  DestinationFolder="$(OutputPath)..\..\AsmScanners" />
    <Copy SourceFiles="$(OutputPath)publish\SetACLNative.pdb"  DestinationFolder="$(OutputPath)..\..\AsmScanners" />
    <Copy SourceFiles="$(OutputPath)publish\SetACLNative.runtimeconfig.json"  DestinationFolder="$(OutputPath)..\..\AsmScanners" />
  </Target>
4

0 回答 0