0

We have our application developed in .Net 6. While using dotnet build/msbuild nuget restore is getting error with letter 'v' we are using along with version number. Please let me know if there is away to inform nuget.restore to ignore letter 'v' as prefix.

Here is our nuget resource files in our project

A.csproj.nuget.g.props file

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
    <RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
    <RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
    <ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
    <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
    <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\.nuget\packages\</NuGetPackageFolders>
    <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
    <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.6.0</NuGetToolVersion>
  </PropertyGroup>
  <ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
    <SourceRoot Include="C:\Users\.nuget\packages\" />
  </ItemGroup>
</Project>

Please let me know if there is a way while restoring nuget package to ignore letter V while restoring.

1
  • If you have a PackageReference and you have a v prefix in the Version metadata for the package, you need to remove the v. The Version metadata only accepts a SemVer version. Commented Jul 1 at 18:49

1 Answer 1

0

I have achieved with a hack by setting version to null and setting version flag after restore and build.

:: GET Build version from RTC pipeline
SET BuildVersion=%Version%

SET "Version="

 %DOTNETBUILDPATH% restore solution path(.sln) 
 
 %DOTNETBUILDPATH% build solution path(.sln)   /p:Configuration=Release

 SET Version=%BuildVersion%

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