简体   繁体   中英

New Project - Invalid NuGet version string: 'VERSION'

When I create a new project from the scratch I am actually facing this compilation issue:

错误描述

In order to solve it, I have to edit each project properties, on the package section and change the default value for "Package Version" configuration. I have to change it from 'VERSION' to some valid version number like 1.0.0.0.

包版本默认值

This is also happening when I checkout code from some of my coworkers, who don't have this issue.

Is there a way to solve it? Is there an environment configuration missing on my local computer?

I am actually using Windows 10 x64, and Visual Studio 2019, but it also fails on vs2017.

.NET uses MSBuild to build projects, which means that all .NET project files are just MSBuild files. MSBuild has an option to pre-process the file into a single file (evaluate all imports, and it conveniently puts xml comments saying the filename the contents were imported from). So, either start a "Developer command prompt", cd to your project directory and run msbuild -pp:pp.txt , or from any command prompt, cd to your project directory and run dotnet msbuild -pp:pp.txt , then open your favourite text or XML editor and search pp.txt for "VERSION". Once you found it, scroll up until it tells you which file defined that property.

My guess is that you have a Directory.Build.props file somewhere on your filesystem somewhere above where you create all your projects that defines the Version property to the value VERSION .

On the system where the Restore is running, check if you have a pre-configured Environment Variable with name 'version'.

MS Build sometimes picks this value to restore the builds.

I was not able to understand where the invalid value 'latest' is coming from. We tried debugging Directory.build.props files for global project property. Even .csproj had no typos or version values specified(In my case version was set to latest, for you it could be null or any any value that is invalid per MS Build.)

Updating version from 15 to 16 didn't help either.

We checked system environment variables and found that one of the variable was 'VERSION' which was set to latest. Removing this variable (eg, unset version) resolved the issue for us.

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