.NET MSBuild Targets AfterTargets =使用dotnet构建打包

时间:2018-11-08 15:42:29

标签: c# .net msbuild .net-core msbuild-task

更新:

似乎也将dotnet build -v d设置为详细时,就会(显然)揭示有关此过程的更多细节

原始:

引用:https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets

我正在使用dotnet build,我的csproj如下:

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <PackageOutputPath>..\packages\</PackageOutputPath>
    <AssemblyVersion>0.1.0</AssemblyVersion>    
  </PropertyGroup>

  <Target Name="CopyPackage" AfterTargets="Pack">
      <Copy
        SourceFiles="$(OutputPath)..\$(PackageId).$(PackageVersion).nupkg"
        DestinationFolder="%USERPROFILE%\.nuget\packages"
      />
  </Target>
  <Target Name="AfterPackMessage" AfterTargets="Pack">
    <Message Text="Copied $(OutputPath)..\$(PackageId).$(PackageVersion).nupkg TO %USERPROFILE%\.nuget\packages" />  
  </Target>
</Project>

我只看到此输出

C:\code\MySolution.net\MyProject.Core (feature-mediator-http)
λ dotnet build
Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 70.34 ms for C:\code\MySolution.net\MyProject.Core\MyProject.Core.csproj.
  MyProject.Core -> C:\code\MySolution.net\MyProject.Core\bin\Debug\netstandard2.0\MyProject.Core.dll
  Successfully created package 'C:\code\MySolution.net\packages\MyProject.Core.1.0.0.nupkg'.

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.68

这里有两个问题:

1)那些Target似乎没有执行

2)AssemblyVersion似乎没有得到应用

dotnet packnuget pack似乎没什么作用

0 个答案:

没有答案