Where are Build variables stored with .net Visual Studio Project Properties?
Hi. I'm making the onerous transition from developing in .net Framework to .net alone. Currently upgrading a load of projects and hit a snag.
The project properties system is very different. I'm wanting to be able to change things before a build such as the Package Version. However, under ProjectProperties>Build, these seem to be stored in a tokenised format:
$(AssemblyName)
$(VersionPrefix)
$(Authors)
etc. I might not be looking hard enough - but where the hell does msbuild pull these vars from??
12 Replies
from other parts in the project properties
these should all be settable
in a .net framework project, you might notice a
Properties/AssemblyInfo.cs
file. this is what stores, among others, package information like description, author, version, etc
this file is no longer necessary in .net, it's generated from the project properties
the project properties can be set and edited in the project file itself, or from the vs project settings. your project file might contain something like this, for example;
(other properties omitted)
this property can then be reused in other properties
in msbuild, accessing a property is done via $(PropertyName)
that's what you might be seeing in the vs project settings when it accesses $(Authors)
, or $(AssemblyName)
Ah thanks for this. Done some more reading and think I would like to still use an AssemblyInfo.cs file rather than alter the project file every time as historically (with Framework) used a script to auto-update the ver number. Would rather not mess with the project file. Is there a way to auto-generate the AssemblyInfo.cs file as it's missing in my .net upgraded code
i would very much recommend getting used to working with project files
it's one of the major benefits of modern .net sdk versions
sdk projects can access environment variables, for example
so - to manually adjust version - I would unload the project, alter the file and reload each time?
you do not need to unload the project
Hmmm...changed it in Project Properties, also checked in proj file, not dice on the build - file version shows as 0.0.0.0




can't say i repro, works for me

aha - had to change to this:
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
You should be able to omit it, that's the default value
it was set to false for some reason 🤷
always knew this transition from framework to .net was goign to be a bumpy ride!
thanks for your help