2017-08-07 50 views
0
<PropertyGroup> 
     <BuildNumber Condition=" '$(BuildNumber)' == '' ">0.0.0</BuildNumber> 
     <VersionPrefix>$(BuildNumber)</VersionPrefix> 
     <VersionSuffix Condition=" '$(Configuration)' == 'Debug' ">dev</VersionSuffix> 
    </PropertyGroup> 
  • 當我編譯該項目時,我沒有收到錯誤信息,並且一切都很正常。

我刪除被稱爲Ninja.Host三號項目,所以請忽略該項目,因爲它僅僅是用於演示目的。

  • 我只能做恢復構建沒有也不發佈

  • 我通過參數作爲/p:BuildNumber=$(Build.BuildNumber)BuildNumber構建任務 vsts tasks

  • 我通過複製任務

  • 複製**/*.nupkg$(build.artifactstagingdirectory)\nuget目錄當我排隊的基礎上我在下面發出警告。 vsts build log

    2017-08-07T03:23:50.2098321Z [command]"C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\src\Ninja.Domain\Ninja.Domain.csproj --configuration release /p:BuildNumber=1.0.353 
    2017-08-07T03:23:50.3518364Z Microsoft (R) Build Engine version 15.1.1012.6693 
    2017-08-07T03:23:50.3518364Z Copyright (C) Microsoft Corporation. All rights reserved. 
    2017-08-07T03:23:50.3518364Z 
    2017-08-07T03:23:51.9897194Z Ninja.Abstractions -> d:\a\1\s\src\Ninja.Abstractions\bin\release\netstandard1.4\Ninja.Abstractions.dll 
    2017-08-07T03:23:52.1097005Z Successfully created package 'd:\a\1\s\src\Ninja.Abstractions\bin\release\Ninja.Abstractions.1.0.353.nupkg'. 
    2017-08-07T03:23:53.6697753Z Ninja.Domain -> d:\a\1\s\src\Ninja.Domain\bin\release\netstandard1.4\Ninja.Domain.dll 
    2017-08-07T03:23:53.7253932Z Successfully created package 'd:\a\1\s\src\Ninja.Domain\bin\release\Ninja.Domain.1.0.353.nupkg'. 
    2017-08-07T03:23:53.7267788Z C:\Program Files\dotnet\sdk\1.0.4\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(104,5): warning : Issue found with package 'Ninja.Domain'. [d:\a\1\s\src\Ninja.Domain\Ninja.Domain.csproj] 
    2017-08-07T03:23:53.7277784Z C:\Program Files\dotnet\sdk\1.0.4\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(104,5): warning : Issue: Prerelease dependency in stable package. [d:\a\1\s\src\Ninja.Domain\Ninja.Domain.csproj] 
    2017-08-07T03:23:53.7277784Z C:\Program Files\dotnet\sdk\1.0.4\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(104,5): warning : Description: A stable release of a package should not have a prerelease dependency. [d:\a\1\s\src\Ninja.Domain\Ninja.Domain.csproj] 
    2017-08-07T03:23:53.7277784Z C:\Program Files\dotnet\sdk\1.0.4\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(104,5): warning : Solution: Either modify the version spec of dependency "Ninja.Abstractions [0.0.0-dev,)" or update the version field in the nuspec. [d:\a\1\s\src\Ninja.Domain\Ninja.Domain.csproj] 
    2017-08-07T03:23:53.7297813Z 
    2017-08-07T03:23:53.7307788Z Build succeeded. 
    
  • 下載的構件,並且具有2個文件,其具有Ninja.Abstractions.1.0.353.nupkgNinja.Domain.1.0.353.nupkg

  • 開業忍。 Abstractions.nuspec這是在Ninja.Abstractions.1.0.353。nupkg

    <?xml version="1.0" encoding="utf-8"?> 
    <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> 
        <metadata> 
        <id>Ninja.Abstractions</id> 
        <version>1.0.353</version> 
        <authors>Ninja.Abstractions</authors> 
        <owners>Ninja.Abstractions</owners> 
        <requireLicenseAcceptance>false</requireLicenseAcceptance> 
        <description>Package Description</description> 
        <dependencies> 
         <group targetFramework=".NETStandard1.4"> 
         <dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" /> 
         </group> 
        </dependencies> 
        </metadata> 
    </package> 
    
  • 開業Ninja.Domain.nuspec這是Ninja.Domain.1.0.353.nupkg

    <?xml version="1.0" encoding="utf-8"?> 
    <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> 
        <metadata> 
        <id>Ninja.Domain</id> 
        <version>1.0.353</version> 
        <authors>Ninja.Domain</authors> 
        <owners>Ninja.Domain</owners> 
        <requireLicenseAcceptance>false</requireLicenseAcceptance> 
        <description>Package Description</description> 
        <dependencies> 
         <group targetFramework=".NETStandard1.4"> 
         <dependency id="Ninja.Abstractions" version="0.0.0-dev" exclude="Build,Analyzers" /> 
         <dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" /> 
         </group> 
        </dependencies> 
        </metadata> 
    </package> 
    

正如你可以看到它有<dependency id="Ninja.Abstractions" version="0.0.0-dev" exclude="Build,Analyzers" />這應該是<dependency id="Ninja.Abstractions" version="1.0.353" exclude="Build,Analyzers" />,並且在本地構建它時,此行爲不適用。在Visual Studio 2017中,它構建了它假定處理正確的依賴信息的方式。

我在想加入明確的nuspec文件,但它會迫使我手動跟蹤引用這是不是我想這樣做。

我很感激任何負擔能幫我解決這個問題。

回答

0

您還需要將/p:BuildNumber=$(Build.BuildNumber)更改爲dotnet restore,因爲NuGet依賴包的版本在還原時被鎖定並寫入obj\project.assets.json文件。請參閱GitHub上的this similar issue

+0

謝謝!它沒有通過版本號和依賴版本變成'1.0.353-dev',這意味着它被稱爲** Debug **配置。 _(這是一個問題,但不是在我的情況下)_ 我用'--configuration $(BuildConfiguration)'調用它不起作用,我將它改爲'/ p:Configuration = $(BuildConfiguration)'和有效。 因此,基本上我需要添加'/ p:Configuration = $(BuildConfiguration)/ p:BuildNumber = $(Build.BuildNumber)'到'dotnet restore' 您保存了我的一天,再次感謝您! – cilerler