tags:

views:

253

answers:

4

I normally build my solution with MSBuild in order to keep Visual Studio responsive and save a bit of time. Right now, what I run at the command line is very simple:

MSBuild.exe /m "C:\MyProject\MyProject.sln"

Up until now, this has worked just fine. However, today I added a class to a class library project whose DLL is loaded via reflection in my app, and I couldn't create an object of the new class. I looked in the debugger at the types contained in the DLL that I had loaded, and my new type wasn't present. I got the same results with Reflector.

When I finally went back to the IDE, right clicked on the project, and chose "Rebuild", my new type showed up in Reflector.

Is there some setting or command line flag I can set in MSBuild to make sure that new changes are caught every time?

+1  A: 

I have found that historically MS IDE does not always save project and solution files when you ask it to... This may have some bearing on the problem, but perhaps not.

however, perhaps it is just as simple as this:

Try adding /t:rebuild

MSBuild.exe /m "C:\MyProject\MyProject.sln" /t:rebuild

Tim
A: 

Try specifying "ReBuild" in your msbuild command line call.

msbuild /t:Rebuild /p:Configuration=Debug

Season to taste.

Rob Hunter
+3  A: 

This probably sounds like a stupid question, but are you sure the new class file was saved? Rebuild usually automatically saves all files, whereas MSBuild does not.

hmcclungiii
In this case it could also be that the project files was not saved.
Bert Huijben
When compiling from Visual Studio and some of the files are open in editors, for c# and VB those files are compiled from the editor buffers instead of the on disk files. (Those files can get out of sync with the on disk version under some very uncommon conditions)
Bert Huijben
+1  A: 

It turned out to be an unsaved file problem. It wasn't actually the new class file; that file was saved. It was the .csproj file that wasn't saved after I added the new class file in the IDE. If I had clicked "Save All" or highlighted the project and clicked "Save", MSBuild would have worked just fine.

Brian Sullivan