tag:help.appveyor.com,2012-11-13:/discussions/questions/25629-one-repo-multiple-projects-2-nugets-and-appveyorAppVeyor: Discussion 2018-09-06T18:34:48Ztag:help.appveyor.com,2012-11-13:Comment/460256672018-09-04T21:18:28Z2018-09-04T21:18:30ZOne Repo, multiple projects, 2 nugets and appveyor<div><p>I am getting closer. Added some before/after build scripts. Now it is complaining about NuGet not being restored! Here is the yml file:<br></p>
<pre>
<code>version: 0.0.{build}
branches:
only:
- master
image: Visual Studio 2017
configuration: Release
clone_folder: C:\sol3
environment:
matrix:
- project_name: Sol3.Infrastructure
- project_name: Sol3.Infrastructure.IoT
before_build:
- pwsh: "Write-Host &quot;---==[ BEFORE BUILD SCRIPT ]==---&quot; \nWrite-Host $Env:project_name\ndotnet --version \ndotnet restore $env:project_name/$env:project_name.csproj"
build:
project: '%project_name%\%project_name%.csproj'
publish_nuget: true
verbosity: normal
before_package:
- pwsh: Write-Host "---==[ BEFORE PACKAGING SCRIPT ]==---"
after_build:
- pwsh: "Write-Host &quot;---==[ AFTER BUILD SCRIPT ]==---&quot; \nWrite-Host $Env:project_name\nif($env:project_name -ieq &quot;sol3.infrastructure&quot;) \n{ \n Write-Host &quot;HERE IS WHERE WE PACK AND PUBLISH THE &quot; + $env:project_name + &quot; NUGET&quot; \n}\nif($env:project_name -ieq &quot;sol3.infrastructure.iot&quot;) \n{ \n Write-Host &quot;HERE IS WHERE WE PACK AND PUBLISH THE &quot; + $env:project_name + &quot; NUGET&quot; \n}"</code>
</pre>
<p>Here is the logs:<br></p>
<pre>
<code>Build started
git clone -q --branch=master https://github.com/KeithBarrows/sol3.git C:\sol3
git checkout -qf d1f3ca4456c1f7d2755b236f8fe02f6760d5a14f
Write-Host "---==[ BEFORE BUILD SCRIPT ]==---"<br>Write-Host $Env:project_name
dotnet --version<br>dotnet restore $env:project_name/$env:project_name.csproj
---==[ BEFORE BUILD SCRIPT ]==---
Sol3.Infrastructure
2.1.401
Restoring packages for C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj...
C:\Program Files\dotnet\sdk\2.1.401\NuGet.targets(114,5): error : Unable to load the service index for source https://keithbarrows.pkgs.visualstudio.com/_packaging/packages/nuget/v3/index.json. [C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj]
C:\Program Files\dotnet\sdk\2.1.401\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj]
msbuild "C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj" /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:GeneratePackageOnBuild=false
Microsoft (R) Build Engine version 15.8.168+ga8fba1ebd7 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 9/4/2018 2:13:16 PM.
Project "C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "bin\Release\netcoreapp2.1&quot;.
Creating directory "obj\Release\netcoreapp2.1&quot;.
C:\Program Files\dotnet\sdk\2.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file 'C:\sol3\Sol3.Infrastructure\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj]
Done Building Project "C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj" (default targets) -- FAILED.
Build FAILED.
"C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj" (default target) (1) ->
(ResolvePackageAssets target) ->
C:\Program Files\dotnet\sdk\2.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error NETSDK1004: Assets file 'C:\sol3\Sol3.Infrastructure\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\sol3\Sol3.Infrastructure\Sol3.Infrastructure.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:11.00
Command exited with code 1</code>
</pre>
<p>Any ideas on why the nuget restore, which works, is not recognized when the build happens?</p></div>keith.barrowstag:help.appveyor.com,2012-11-13:Comment/460256672018-09-04T22:19:51Z2018-09-04T22:19:51ZOne Repo, multiple projects, 2 nugets and appveyor<div><p>It is private nuget feed, correct? In this case you have to add a nuget source before using it with <code>nuget sources add</code> command. Otherwise <code>nuget/dotnet restore</code> unable to authenticate against it. Secret you pass to this command can be store as a <a href="https://www.appveyor.com/docs/build-configuration/#secure-variables">secure variable</a>.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/460256672018-09-05T18:24:48Z2018-09-05T18:24:48ZOne Repo, multiple projects, 2 nugets and appveyor<div><p>I've gotten a lot further. Dropped trying to write project level appveyor.yml files, started using the Environment matrix in the settings page, writing my own build script in PSCore.</p>
<p>In the build matrix I list each project I want to build. Then, I run this build script for .NET Core 2.x:</p>
<pre>
<code>Write-Host "---==[ BEFORE BUILD" $env:project_name "SCRIPT ]==---"
Set-Location .\$env:project_name
dotnet restore ###$env:project_name/$env:project_name.csproj
Write-Host ""
Write-Host "---==[ BUILD" $env:project_name "SCRIPT ]==---"
dotnet build ###$env:project_name/$env:project_name.csproj -c Release
Write-Host ""
Write-Host "---==[ AFTER BUILD" $env:project_name "SCRIPT ]==---"
if($env:project_name -ilike "sol3.infrastructure*")
{
dotnet pack --no-build /p:PackageVersion=$env:APPVEYOR_BUILD_VERSION
nuget push .\bin\release\$env:project_name.$env:APPVEYOR_BUILD_VERSION.nupkg -ApiKey [myKey] -Source https://ci.appveyor.com/nuget/keithbarrows/api/v2/package
}
Set-Location ..</code>
</pre>
<p>Everything seems to now work, the builds build correctly, the packages push to my account nuget feed on AppVeyor. However, I cannot access the account nuget feed. Maybe it is just temporary?</p></div>keith.barrowstag:help.appveyor.com,2012-11-13:Comment/460256672018-09-06T18:11:50Z2018-09-06T18:11:50ZOne Repo, multiple projects, 2 nugets and appveyor<div><p>This can be closed. I got it all working except for being able to access the nugets after build is done.</p>
<p><a href="https://help.appveyor.com/discussions/questions/25682-how-do-you-access-the-account-feed-from-outside-appveyor">https://help.appveyor.com/discussions/questions/25682-how-do-you-ac...</a></p></div>keith.barrowstag:help.appveyor.com,2012-11-13:Comment/460256672018-09-06T18:34:46Z2018-09-06T18:34:46ZOne Repo, multiple projects, 2 nugets and appveyor<div><p>Great, we will help with another ticket shortly.</p></div>Ilya Finkelshteyn