I'm creating a batch script which will get latest version of the code of an application, then build it using msbuild. Everything works until the msbuild part. Here's the line that runs msbuild:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe "code/Solution.sln" /p:Configuration="Debug"
And the thing errors all over the place - all the errors say something like:
C:\code\project1\codefile1.vb(882): error BC30009: Reference required to assembly 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' containing the implemented interface 'System.Xml.Serialization.IXmlSerializable'. Add one to your project.
Everything builds without errors from from Visual Studio 2008. What's going on here?
To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.
To install MSBuild on a system that doesn't have Visual Studio, go to Build Tools for Visual Studio 2019, or install the . NET SDK. If you have Visual Studio, then you already have MSBuild installed. With Visual Studio 2022, it's installed under the Visual Studio installation folder.
Click on System and Security and then on System. In the left pane, click on Advanced system settings. At the very bottom of the pop up, click on Environment Variables. Edit the Path variable and append the folder's path that contains the MSBuild.exe to it (e.g., ;C:\Windows\Microsoft.NET\Framework64\v4.
Cleaning up specific projects: msbuild MyProjectFile1 /t:Clean msbuild MyProjectFile2 /t:Clean ... This has to be repeated for all projects you need to clean, because MSBuild only accepts single project on command line.
This is probably most detailed descriptions on what is going wrong:
MSBuild Can't Find Secondary References
Resolving Binary References in MSBuild
In short: Your project references assembly X. X contains a class, that implements interface from assembly Y. Your project does not reference Y, so MSBuild fails. Studio acts a bit smarter and finds the second level reference.
Do just what it says and add a reference to System.Xml to your project.
Project->Add Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With