简体   繁体   中英

C# NuGet package error in Azure DevOps with image

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.

在此处输入图像描述

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.

在此处输入图像描述

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.

在此处输入图像描述

Update

The project is Azure DevOps is exactly the same as the local one. The project settings are the same as above.

When I run the pipeline in Azure DevOps I have this warning

WARNING: NU5118: File '/home/vsts/work/1/s/PSC.Extensions/bin/Debug.net5.0/ref/PSC.Extensions.dll' is not added because the package already contains file 'lib.net50/PSC.Extensions.dll'

WARNING: NU5115: Description was not specified. Using 'Description'.

WARNING: NU5115: Author was not specified. Using 'vsts'.

So, I changed the pipeline and in the package step I added the

  • task: NuGetCommand@2

     displayName: Prepare the package inputs: command: 'pack' packagesToPack: '**/*.csproj' versioningScheme: 'byEnvVar' versionEnvVar: 'PackageVersion' buildProperties: 'Authors="Enrico Rossini";Description="Test"'

but nothing.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM