0
votes

I'm want to create a nuget package which containes only resources (images, scripts...).

So I created a new empty asp.core project.

The project look like this

MyProject
--.Nuget
-----MyProject.Nuspec
--Content
----Img
------myimage.gif
--Script
----myscript.js
--.gitlab-ci.yml
--MyProject.csproj
--MyProject.sln

In this project, I add a .nuget folder with a .nuspec file

Here is the content

<?xml version="1.0"?>
 <package>
   <metadata>
     <id>myProject</id>
     <version>$version$</version>
     <authors>MyName</authors>
     <owners>MyName</owners>
     <requireLicenseAcceptance>false</requireLicenseAcceptance>
     <description>myProject</description>
     <releaseNotes>First implementation with nuget</releaseNotes>
     <copyright>Copyright © ME</copyright>
     <dependencies>
      <dependency id="jQuery" version="[3.2.1]" />
      <dependency id="bootbox" version="[4.3.0]" />
     </dependencies>
   </metadata>
  <files>
    <file src="..\Content\img\myimage.gif" target="content\Content\img" />
    <file src="..\Script\*.js" target="content\Scripts" />
  </files>
 </package>

And here is the content of the yml

image : microsoft/dotnet:latest

before_script:
  - 'dotnet restore myProject.sln'

stages:
  - build
  - test
  - deploy

job1:
 stage: build
 script:
  - 'dotnet msbuild MyProject.sln /t:Clean,ReBuild /p:Configuration=Debug;Platform="Any CPU"'
  - 'dotnet msbuild MyProject.sln /t:ReBuild /p:Configuration=Release;Platform="Any CPU"'
  - 'dotnet pack "MyProject.csproj" /p:NuspecFile=".Nuget/*.nuspec" -v n --include-source --include-symbols --no-build'
  - 'dotnet nuget push *.nupkg -k myApi -s https://www.myget.org/F/myfeed/api/v2/package'
 only:
   - master

The build seems to work successfully, but every time it crash on nuget push

error: File does not exist (*.nupkg).

I'm missing something, but I can't find out the problem.How can I get my nupkg?

Any help is welcome

1
Is 'dotnet pack' produce any nupkg if you run it from command line?Roman Patutin
No it produce nothing. That why I'm thinking I'm missing a part of this.dpfauwadel

1 Answers

2
votes
  1. A little trick: you can change verbosity of output 'dotnet pack' using -v switch.
  2. You do not need to use keys '--include-source --include-symbols' if you need only add js and images in your package.
  3. NuspecFile do not accept '*'.

So this is the string that allows me to create nuget:

dotnet pack "MyProject.csproj" /p:NuspecFile=".Nuget/MyProject.Nuspec" -v d --no-build -c Release

Please, try to change you YML file for using it.