0
votes

I'm creating a NuGet package to distribute in my organization. Following a post online, the pipeline is working. In Azure DevOps I created the Artifacts, the pipeline buils the NuGet package and push it in the Artifacts as I expected. I'm using Visual Studio 2021.

So, in the property of the project I selected an icon.

enter image description here

I committed this change and now Azure DevOps gives me an error. So, I created a folder in the project called Images and here I pasted the image I want to use and updated the path from Visua Studio. The error is the same.

##[error]CSC(0,0): Error CS7064: Error opening icon file /home/vsts/work/1/s/Images/psc_logo.ico -- Could not find a part of the path '/home/vsts/work/1/s/Images/psc_logo.ico'.

Also, in Visual Studio I see the package but the description and the author are different from what I filled in the property.

enter image description here

How can I fix it?

Update

Although I added the properties in the .csproj file, Azure DevOps ignores completely them.

<PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
    <Description>Collection of useful functions</Description>
    <Copyright>Enrico Rossini</Copyright>
    <PackageTags>extensions, c#, net50</PackageTags>
    <SignAssembly>False</SignAssembly>
    <Company>Enrico Rossini</Company>
    <PackageReleaseNotes>Collection of useful functions</PackageReleaseNotes>
    <PackageIcon>psc_logo.png</PackageIcon>
    <ApplicationIcon>psc_logo.ico</ApplicationIcon>
    <GenerateDocumentationFile>True</GenerateDocumentationFile>
    <Authors>Enrico Rossini</Authors>
    <AssemblyVersion>1.0.2</AssemblyVersion>
    <FileVersion>1.0.2</FileVersion>
    <Version>1.0.2</Version>
</PropertyGroup>

<ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
    <None Include="psc_logo.ico" Pack="true" PackagePath="" />
    <None Include="psc_logo.png" Pack="true" PackagePath="" />
</ItemGroup>

You see in the picture below that authors and description has the default values.

enter image description here

1
Devops is expecting that file to be in the source path (/s), and it's not. It looks like you should either check it in, or fix your path to your nuget - Stuart.Sklinar

1 Answers

1
votes

C# NuGet package error in Azure DevOps with image

According to the error message, it seems you need add the file psc_logo.ico to the source control, the repo.

But, if you want to specify the icon for the package, then the way you are setting the icon is incorrect.

The package settings should be specified in the Package tab.

And for the icon of the package, you could specify following Property in the project file:

<PropertyGroup>
    ...
    <PackageIcon>icon.png</PackageIcon>
    ...
</PropertyGroup>

<ItemGroup>
    ...
    <None Include="images\icon.png" Pack="true" PackagePath="\"/>
    ...
</ItemGroup>

You could check the document icon and Packing an icon image file.

For the description and the author, make sure you have define them in the project file and the nuget pack task works on your project file .csproj:

  <PropertyGroup>
    ...
    <Version>1.0.1</Version>
    <Description>Test project</Description>
    <Authors>Leo</Authors>
    <PackageIcon>psc.png</PackageIcon>
    ...
  </PropertyGroup>