My solution have a mix of Visual Basic and C# projects, in total 32 projects. When I rebuild from Visual Studio 2017, all projects restores from nuget.org. When I trigger a .bat file, only 16 of the projects restore packages from nuget.
This line exists in .bat file.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\msbuild" Projectname.sln /p:Configuration=Debug /t:Rebuild
I found a pattern, that in the .sln file, every projects that restores nuget have following:
{5E..guid..02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU{5E..guid..02}.Debug|Any CPU.Build.0 = Debug|Any CPU{5E..guid..02}.Debug|x86.ActiveCfg = Debug|x86{5W..guid..02}.Debug|x86.Build.0 = Debug|x86
The ones that does not restore nuget have:
{0A..guid..3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU{0A..guid..3B}.Debug|Any CPU.Build.0 = Debug|Any CPU{0A..guid..3B}.Debug|x86.ActiveCfg = Debug|Any CPU{0A..guid..3B}.Debug|x86.Build.0 = Debug|Any CPU
Note the difference: the two bottom lines have 'Debug|x86' when it works. Even for the projects that does not restore nugets, the Build tab in Visual Studio says Platform target: x86 in drop down menu.
If I change the .sln file manually to x86, it restores back to Any CPU after a new rebuild.
Any idea on how to make every project target x86 so the nuget packages gets restored from the .bat file?