MSBuild not respecting AssemblyInfo patcher

Answered

Hey guys,

MSBuild isnt using the values provided by the ASsemblyInfo updater. I can confirm the updater is patching the file, but when MSBuild runs it ignores the values in the assemblyinfo file.

 

Above: I updated the AfterBuild to print

version is @(Targets->'%(Version)')
AssemblyInfo text is $(ProjectDir)Properties\AssemblyInfo.cs

Thats whats highlighted in red.

I think I'm running afoul of some MSBuild cache but I was ripping my hair out trying to find it.

If I modify the AssemblyInfo files myself, and rebuild, it takes the values in the file.

Does anybody know why my AssemblyInfo is being ignored by MSBuild? Is there a "NoCache" or similar option I can give MSBuild?

0
3 comments

Hello Geoff,

Sorry for the delay; is the issue still topical for you?
As I could see, command-line call of MSBuild should read the AssemblyInfo.cs anew, so maybe this has to do with the fact that MSBuild.exe is invoked from the VS installation folder. Have you checked if the same works in case build step is using MSBuild or .NET runner? (latter is recommended because since 2019.2.3 active support is stopped for both VS and MSBuild runners - see https://www.jetbrains.com/help/teamcity/net.html#migrating-to-net-from-sln for the details on migration).

Alternatively, you could define data in AssemblyInfo programmatically, via AssemblyInfo task in the BeforeBuild, and pass the version number as a command-line parameter - https://stackoverflow.com/questions/8446693/specify-assembly-version-number-as-a-command-line-argument-in-msbuild. As there is no file read in this case, it should not be affected by the issue. Would this approach work for you?

0

When I run on my local machine with dotnet build my.sln, I get:

C:\Users\geoff\Code\ansys\ANSYSBootstraps.csproj(89,5): error MSB4062: The "MSBuild.Community.Tasks.Zip" task could not be loaded from the assembly C:\Users\geoff\Code\ansys\packages\MSBuildTasks.1.5.0.235\build\\..\tools\MSBuild.Community.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

Which is interesting for `C:\Users\geoff\Code\ansys\packages\MSBuildTasks.1.5.0.235\build\\..\tools\MSBuild.Community.Tasks.dll ... Cannot find the file specified`. Its interesting because that path is quasi-legal, maybe devenv handles it but dotnet build does noo?

Regarding your second solution, who defines the AssemblyInfo task? there isnt one built into the tooling and there doesnt appear to be one in the community library I'm dependent on. Its clear that I need to spend some more time with dotnet tech, specifically the newer stuff, to see if i can familiarize myself with whose interpreting what. I think its also reasonably clear that visual studio's devenv does several things very differently than dotnet build, so trying to keep both in sync might not be worth it, especially considering the size of this codebase.

Looking at this, these projects and the solution file seem pretty ad-hoc; when I find the time I think im simply going to delete everything except source-code and re-build it. I'll update this issue once I've moved to `dotnet build` and will post my results.

0

Hello Geoff,

Sorry for not mentioning the source - it appears the AssemblyInfo task is supplied with MSBuild Community Tasks package (https://github.com/loresoft/msbuildtasks). I believe it is the one you have as a dependency - maybe the version is different? 

Looking forward to hear from you regarding the issue.

0

Please sign in to leave a comment.