New Build with MSBuild does not include new class - msbuild

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?

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.

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

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.

Try specifying "ReBuild" in your msbuild command line call.
msbuild /t:Rebuild /p:Configuration=Debug
Season to taste.

Related

Application.Designer.vb file is duplicated when change startup form for VBNET

I have a VBNet project in Visual Studio 2019, today I face this issue suddenly:
When I change the startup form (which I did million times before without errors) to another form, the file Application.Designer.vb is duplicated with new name Application1.Designer.vb
This file leads to build error: 'Protected Overrides Sub OnCreateMainForm()' has multiple definitions with identical signatures.
If I try to remove file Application1.Designer.vb then File Not Found error will be thrown.
If I remove the compile tag for Application1.Designer.vb in the project vbproj file then build fails but no error is shown.
I could mess up with the app settings but I am now completely stuck and have no idea to run my project since these are all auto generated.
Please suggest anything that I should check. Thanks all!

Debug Design Mode in Visual Studio not breaking

So I am currently unable to open a Form and get the following error:
System.ComponenetModel.Design.ExceptionCollection was thrown.
or:
The designer loader did not provide a root component and has not indicated why
Usually the way to solve this is to open another instance of Visual Studio with the same project, attach the debugger to the other Visual Studio and try to open the form.
However, that does not seem to be working. The debugger does not break when the error is hit, and attempting to 'Break All' at any other point does not show me the source code and just the screen saying:
Your app has entered a break state, but there is no code because all threads were executing external code (typically system or framework code).
Attempting to put break points also results in:
The breakpoint will not currently be hit. No symbols have been loaded for this document
Am I missing a setting? Incorrect Setup?
I have been battling this for half a day and thoroughly search the interwebs with no luck thus far. My designer is also fairly complex and lengthy which means trial and error is an absolute last ditch option.
First attempt to resolve:
you may have tried it already. Right click the Solution in solution explorer, click "clean solution", this deletes all the compiled and temporary files associated with a solution.
Do a rebuild of the solution and try to debug again.
Second attept to resolve:
Start debugging, as soon as you've arrived at a breakpoint or used
Debug > Break All, use Debug > Windows > Modules. You'll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You'll get a dialog that lists all the directories where it looked for the .pdb file for the assembly. Verify that list against the actual .pdb location. Make sure it doesn't find an old one.
In normal projects, the assembly and its .pdb file should always have been copied by the IDE into the same folder as your .exe. The bin\Debug folder of your project. Make sure you remove one from the GAC if you've been playing with it.
third attept to resolve:
Disable the "Just My Code" option in the Debug/General settings.
there are might be other causes to your problem, i picked them from here. you may try other solution to try resolve your issues. Fixing "The breakpoint will not currently be hit. No symbols have been loaded for this document."

Changes in the code or the designer won't update when debugging

I am trying to debug my VB.net app in Visual Studio Express 2010, when I realized my changes will not update on my form-on the designer or in the code. After looking online, I found that you should clear out the "Debug" folder under the bin. That worked-for only one time. Now it went back to the older version and when I delete it again, it doesn't change. When I build the project and run it from the "Release" folder, it works perfectly, but when a error occurs at runtime, it won't show where the error is because it is running independently.
Thanks in advance.
(I have Windows XP SP3)
I had the same problem. Frustrating problem....? Close the project, go to debug bin/folder, delete these files, reopen project and rebuild it (F5).
- .exe
- .pdb
- .vshost.exe
- .vshost.exe.manifest
- .xml
it works 99.99%.......thanks
Before I'd create a new project, I'd copy all of the code-behind (including the code that creates the controls that you're not supposed to touch) into another form. That may be all you need to do. Try compiling that form and running it and see if it's good. If so, you won't have to create a whole new project and can just delete the old form.
I would think there's something causing this that would be much easier to to fix. Are there any config files or anything like that? Are you building to the right location?
It's been a while since I've done winforms, but I remember this happening in VS 2005 and I just created a new form and copied the code-behind into another winform and compiled.
Hope this helps.
mmm... if it was for me, with such a weird bug, i would create a new project then insert the files (not as a link, but a copy) in the project, and i most likely all will work fine after... Faster than finding where-the-hell is that wrong parameter...
So how do you do that ? Well create a new project, choose the folder and name, change namespace in settings if needed, then in project explorer Add existing item, then Browse and select your code and xaml (and other maybe) files. Let us know.
This happened to me as well. I believe the /bin and /obj folders of my application must've been locked for by some other application. Before manually deleting them I tried running Visual Studio as an administrator and did a Clean and a Rebuild which worked. If it doesn't work for you, try deleting the folders manually.
Close VS
Press Ctrl + Alt + Delete
Choose "Task Manager"
In the "Process" tab in "Task Manager" find your "ProjectName.EXE" and click "End Task"
Restart VS
I have the same problem, but i changed the solution config next to the start button from debug to release and that fixed my problem, try it :)
"Save all" works for me in VS 2010 VB, in Debug and Release mode.
I put the "Save all" icon next to the Run and Build icons.
First make sure your Localizable Property of you form is set to FALSE

How to set breakpoint in DLL

I break my code modules up in DLLs alot.
When I add one of those DLLs to my project, how can I browse it's code to set breakpoints?
If you created the DLL, add the DLL's Project to your solution. You can do this by right clicking on the Solution at the top of Solution Explorer and clicking Add... > Existing Project
One solution can contain many projects. You set your executable as the startup project. You can then use Solution Explorer to find the Code in the Modules and do what you like, set breakpoints, make changes, etc.
Make sure the DLL is in your solution (assuming you use visual studio) AND is referenced by the process you are trying to debug. Then the execution should come by your breakpoints. IF NOT, you will notice the dot of the breakpoint is an empty circle.

Need to build another EXE

I wish to have two EXE files in my project. Say one EXE has startup form ABC.vb
and other is BCA.vb
I am not able to change the name in Build so whatever is my startup file, my exe file's name remains the same. How to change it?
A project builds to one assembly, no matter what.
What you need to do is add another project to your solution. You can do this by right clicking in the tree, and going to New... Project. Then, drag your code that you want to build separately into this new project.
After this, when you build, you will get two EXEs, or whatever the project is set to.