2

I'm having trouble setting the RepositoryUrl tag within my NuGet package. It just doesn't seem to be reflected in the built output and the documentation for where exactly it should go is extremely unclear.

Here is my .csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <PackOnBuild>true</PackOnBuild>
    <Authors>Gerard Wilkinson</Authors>
    <Description>Active Band Comms library.</Description>
    <PackageId>ActiveBand.Comms</PackageId>
    <PackageLicenseUrl>https://github.com/think-active-labs/activeband-comms/blob/main/LICENSE</PackageLicenseUrl>
    <Owners>Think Active Labs Ltd.</Owners>
    <PackageProjectUrl>https://thinkactivekit.com</PackageProjectUrl>
    <Summary>Use this package when you are rolling your own Bluetooth comms solution.</Summary>
    <Title>ActiveBand Comms library.</Title>
    <PackageVersion>2.0</PackageVersion>
    <ReleaseVersion>2.0</ReleaseVersion>
    <PackageIconUrl>https://raw.githubusercontent.com/think-active-labs/activeband-comms/main/pkg-logo.png</PackageIconUrl>
    <Copyright>2021</Copyright>
    <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
    <RepositoryUrl>http://github.com/think-active-labs/activeband-comms</RepositoryUrl>
    <RepositoryType>git</RepositoryType>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DefineConstants>TRACE;DEBUG;NETSTANDARD2_0;DEBUG_COMMS</DefineConstants>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="Bluetooth\" />
    <Folder Include="Interfaces\" />
    <Folder Include="Values\" />
    <Folder Include="Commands\V2\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="NuGet.Build.Packaging" Version="0.2.2">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\ActiveBand.Comms.Service\ActiveBand.Comms.Service.csproj" />
  </ItemGroup>
</Project>

This is the built .nuspec:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>ActiveBand.Comms</id>
    <version>2.0.0</version>
    <title>ActiveBand Comms library.</title>
    <authors>Gerard Wilkinson</authors>
    <owners>Think Active Labs Ltd.</owners>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <licenseUrl>https://github.com/think-active-labs/activeband-comms/blob/main/LICENSE</licenseUrl>
    <projectUrl>https://thinkactivekit.com/</projectUrl>
    <iconUrl>https://raw.githubusercontent.com/think-active-labs/activeband-comms/main/pkg-logo.png</iconUrl>
    <description>Active Band Comms library.</description>
    <summary>Use this package when you are rolling your own Bluetooth comms solution.</summary>
    <releaseNotes></releaseNotes>
    <copyright>2021</copyright>
    <language></language>
    <dependencies>
      <group targetFramework=".NETStandard2.1" />
    </dependencies>
  </metadata>
</package>

You can see all properties are respected except the RepositoryUrl I cannot understand why. I've tried moving it into a block of its own and everything all to no avail. Does anybody know why this may not work? I've tried testing it with a dotnet build with build package ticked and botnet pack neither seem to add the right property to the nuspec.

I need it to work to get my packages into GitHub Packages.

1 Answer 1

1

I have exactly the same problem. As a workaround you might try this:

<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PrivateRepositoryUrl>https://github.com/your/private.git</PrivateRepositoryUrl>

Found a hint here: https://github.com/NuGet/NuGet.Client/blob/d21029641e348e06742f5f563edf084ed811ec3a/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets#L292

1
  • Okay in my case it was a Directory.Builds.targets file with the content <RepositoryUrl>$(PackageProjectUrl)</RepositoryUrl> ... a copy paste error Commented Jun 7, 2022 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.