I want to make MSBuild targets to make setup file and to deploy it. Right now I'm using build configurations for that. So I have 'Debug', 'Release', 'Make setup' and 'Deploy setup' configurations. And when I want to make setup I have to switch to 'Make setup' configuration and run build. And if I forget to switch back to 'Debug' and run build I'll have to wait again while it is making a setup file. It doesn't seem like natural way to do this things to me. Besides, to edit my build file I have to unload project.
I've seen much more comfortable way to do this with Ant in Eclipse:
You just double click target you want and it'll build it. Also you can edit build file without closing anything.
So the question is how to make ant-style builds with visual studio? Is there a plugin or something? I mean both MSBuild and Ant scripts will do, but I want this functionality integrated in VS and work with C# projects.
You can use msbuild's /p:Configuration=DeploySetup flags to do this from command line.
To make your life easier, you can create a batch(.bat) file that will do that.
Related
I have been manually copying dlls, exe, etc. from a "C# Command Line" project to a UNC server share to be executed by a scheduled task.
Does anyone have a suggestion how I can turn this into a simple operation in Visual Studio?
Here is what I have tried:
Publish wizard. It asks how users will install the application, which is totally irrelevant to my situation. I just want to put it out on a server share.
Project Properties -> Publish. This seems pretty much to be the same as the publish wizard.
Batch file or PowerShell script included in project. I don't see an easy way to launch it from within Visual Studio.
If you just need to copy the exe/dlls from output folder you can have a Post-build event in your Visual studio and specify XCOPY command to copy output of the folder to your server shared folder like:
XCOPY $(OutDir) \\Server\folder
If you do not want to copy on each build then you have to manually copy the files in the server. You can write a batch file and execute that once you are done. I am not aware of any direct method in visual studio that does it for you.
Use the Post-build event to xcopy the files. You'll want to make it conditional so you'll only copy when the Release build is selected. Make it look like this:
if not "$(OutDir)" == "bin\Release\" goto skip
xcopy /d /y "$(TargetDir)*.*" \\foo\bar
:skip
I do not want to deploy on every build event, and I tend to always build in Debug mode, so Hans' advice on putting conditions into the build event doesn't fit my situation.
Why do I always use Debug mode? My apps are small and for internal use. Performance is typically bound by external constraints, not C# code performance or memory size. If it wasn't a drop-down menu that remembers its state, I would be more comfortable using it. When I do use it, I forget, and then I'm compiling in release mode all the time and wondering why the .exe and .dlls aren't getting updated in the Debug folder.
My imperfect solution is to include batch files within my project, and manually start a command shell window to run them. This isn't the solution I wanted, but it is the best compromise for me.
I have a really big project and what i am trying to do is this:
Occasionally, i have to make few (minor) changes in a single class.
Since this is a minor change, i really hate to open visual studio (ver 2010) and wait for all projects to load.
Instead i open notepad, change that particular file use msbuild.exe to build the entire solution.
Now the question is,
How to get the build status from msbuild.exe ? (i plan to write a nice gui or a web application from which after i invoke
this msbuild.exe, i can get the build status, show to the user)
Is this really a good idea to use msbuild.exe in vs2010 or vs2012? (I saw http://msdn.microsoft.com/en-us/library/ms171452(v=vs.90).aspx specify the supported
version as Visual studio 2008. Though this is working in vs2010, is this the correct way of doing it?)
thanks in advance.
Don't reinvent the wheel, use a build system that does everything you want (and more) for you. Look at Jenkins for example or TeamCity (see the image on the homepage of the latter: showing progress all over the place..)
Definitely yes. Since VS2010 Visual studio itself uses msbuild to build your projects (since they are msbuild scripts as well). And in some upcoming version even the solution file will be an msbuild file.
I have a solution with a lot of C# projects. The dependencies are not cyclic and when I build a high level DLL it appears to be rebuilding all the project referenced DLLs that it is linked to before running the program.
This seems to be unneccessary because I did not change the code in those DLLs and they are at a lower level so the changes I made in the top level DLL should in no way effect the low level DLLs.
How can I tell visual studio to only build DLLs that depend up the hierarchy chain not both ways.
Go to Tools->Customize
A dialog will open. Go to Commands tab. In menu barradio select Build | Project only. Assign a shortcut to it and use it.
When visual studio checks dependencies, it runs the build process. This is not necessarily building your project. In Visual Studio, if you navigate to Tools->Options...->Projects and Solutions->Build and Run you will see a drop downs labeled MSBuild project build output verbosity. If you change this to Detailed. When you build, you will see, in the output window, that it is verifying whether or not files have changed in order to determine if it should rebuild the project. This is why it appears to be building every time.
You should use the following setting:
"Only build startup projects and dependencies on Run" under Tools / Options / Projects and Solutions / Build and Run.
I have a visual studio 2010 web project that when I publish it in debug mode the application works fine and is the latest build.
However, when I try to click the play button/debug mode (in the same build configuration as what I published in) the assembly version is older than the most current one. As mentioned, this is a asp.net application using a c# class library as a reference (also in the solution) and I am debugging using Visual Studio's built-in web server.
I've tried everything I could think of at first in all different combinations as follows:
Clean solution
Clean each individual project
Build solution
Build each individual project
Rebuild solution
Rebuild each individual project
I tried to use a different browser and cleaned my cache as well.
Has this happened to anyone? How can I correct this issue?
It is most likely not set to build. To test this, try build then debug and see if things work. If so, then it is definitely not set to build.
To solve this, open up the Solution Properties. Go to Configuration Properties >> Configuration. Then run down to the project in question and check the Build checkbox. You will then be able to debug again.
This one bit me when a coworker decided the build of the UI was taking too long for his testing and removed it from the build. After discovering the issue, I had him create a separate solution to test in isolation. Yes, multiple solutions can contain the same project(s).
did you try deleting your bin and obj folders and removing your assemblies from the GAC? I would guess that THIS is the problem.
Don't forget to clean your Temporary ASP.Net (c:\WINDOWS\Microsoft.NET\Framework[version]\Temporary ASP.NET Files) files.
After that, do a rebuild and try.
Also, for local development, if you can, then do not GAC assemblies. GAC them while deploying to integration environment. THis will help speed up development a bit.
I have an Office add-in project with a setup project for deployment (using VS 2008), and I need to build the same product in a few different flavours.
I'm looking for a good way to make the installer resources dependent on the build configuration. The product name, manufacturer, manufacturer url, author, etc., etc. properties should be different for each of the builds. Also, the images shown in the installer UI will be different as well.
If possible, I'd like to do this without creating a new project for each different UI.
I believe this could be done using the ORCAS tool and build events, but this approach seems overly complex and fragile.
Does anyone have any ideas on a clean way to go about doing this?
Another option, although it is a bit more work up front, is to throw the setup project out the window and use e.g. WiX instead (http://wix.sf.net)
You could manually make copies of the vddproj file and edit them with a text editor. I admit, this is not a very robust solution and you would have to repeat this step every time the content of your setup changes.
I think the best way is to create hand-made NAnt script.
Explaination:
NAnt is a build tool that besides building can execute scripts. By creating scripts and targets you can modify files that are checked out from your SCM, and then order them to build. Check out official NAnt site for more informations.