According to this link Visual Studio Integration (MSBuild) "Clicking Publish will execute a target named PublishOnly in the project.". Now what I am trying to do is define my own target and execute it when clicking on the "Publish" menu option, however this doesn't seem to work. When I do that I got the Publish Wizard.
I was able to customize the Build/Clean/Rebuild targets but no luck with the PublishOnly.
Just to add one more thing, I didn't import any of the MS provided targets (Microsoft.CSharp.targets)
How do I disable the Publish Wizard and execute my own custom target?
On the same note, what I would like to do is creating a language independent project type which will allow me to add various types of files and customize the basic targets of the project (Build, Clean, PublishOnly) and execute them from within the VS IDE.
I know this is another question although somehow related, so could anyone give some directions, share some similar experience or let me know if this is even possible?
Thanks in advance
Julian
Take your custom target and add AfterTargets="Build". This way your publish target will always execute after your build and you won't have to access a wizard.
More on this:
http://www.writebetterbits.com/2008/02/deploying-aspnet-web-application.html
Related
This is more question of curiosity, the behavior is annoying, but something I can live with.
I'm working on 64b only C++ application in Visual Studio. It consists of more projects, and I deleted the Win32 Configurations from all of them (and also Win32 Solution Configuration). But, when I add new project, it is Win32, and also creates Win32 + MixedPlatforms Solution Configurations, and I need to go to Configuration Manager and delete those.
Is there any configuration how to forbid this? I'm using VS2012.
Thanks
It is pre-baked in the project template that you selected to get your project started. VS2012 makes it easy to customize that template. Get started with your favored standard template. Modify it, like using Build + Configuration Manager to first add the platform target you want, then deleting the Win32 configuration you don't want. Etcetera.
Then use File + Export Template. Keep the "Project template" selection, Next, fill out the dialog and save it. Presto chango, pick that template for your future projects.
I am using this extension (https://github.com/ceztko/SolutionConfigurationName) to put solution output all in one folder. It is working splendidly on our development machines. (I modified the source to support VS2012 installation)
We are now trying to run a build using devenv.com, but it seems that the macros are not being evaluated properly --or rather, they are an empty string ""
Does anyone know if devenv.com plays nice with extensions? Or maybe the workflow for a headless build is different such that the extension is not getting triggered? It uses UpdateSolution_Begin to update the variables.
tia
A headless build won't load that extension, and definitely won't go triggering solution events like that.
To be honest, this feels strongly like an XY problem. A solution build results in the MSBuild Configuration property being specified to each individual project, and I can't think of any scenario where you wouldn't simply be able to base a build customization on that property. For the Roslyn codebase itself we direct all OutDirs for all projects by simply having a single msbuild .targets file that defines the output path, and then we include that in all projects. Very clean, and doesn't require VS extensions to be installed, or even VS installed at all in order to do a build.
When I build my Setup Project another given project (CustomActions.vsproj) isn't built. It happens that the post build script needs that CustomActions.vsproj's binaries. I could build it manually, but I want to automate this so when another developer download the solution from the repository he won't have to know this trick.
I could automate this by including the CustomActions.vsproj's output in the setup. But I don't want to use this solution because this output shouldn't be included in the MSI.
In VS 2010 in the solution navigator there is a small icon called "Launch Conditions editor".
There you can search on the target machine for resources and create "Launch conditions" which binds your wanted message texts ("The file xx was not found...") against the property chosen for the resources.
When I added CustomActions.vsproj's output I could remove it from the Files section and keep it in the build process. This was exactly what I needed.
I am working on a c++ solution which contains 20 projects. My first project builds and I run it as a pre-build event for rest of the projects. Now this executable actually creates some c++ files which should get added to all the other projects which are yet to be compiled. How should I do this? (Using VS2008)
Here are few solutions I thought.
Solution 1:
Let the exe update the vcproj file for all the remaining projects. But in this case as the project is on in VS, it creates some reload popup which I dont want. So is there any way to suppress this popup and just save the changes.
Solution 2:
Visual Automation:
I was just going through some automation API.
The solution and project interface methods would help in adding new file. But will it not create a new pop up as the previous on? Can I use MSbuild here?
You can simply use Generated_*.cpp (or similar pattern) as name of items for corresponding group in project. Than when project is build it will pick up all matching files, even once generated during pre-build steps.
If number of files is small you can just add them to the project directly (which I believe is ok even if they are missing before build).
Note that it may be good idea to generate files into separate folder (like obj\....) so you don't run into cases when someone mistakenly checks in generated files.
I have a little program I wrote to download all NuGet packages for a solution. I would like to setup a pre-build event that would run this program every time I build.
But I need it to run before the first project starts to build. I could look at what is currently building first, and put it on that project's pre-build event, but that is fairly brittle. Any time I add a new project or update references between projects, I would have to double check that the "first" building project is still the first one.
So, what I really need is a way to do this before any building really starts. I have heard of Visual Studio macros. But those are not something that gets checked in so I would prefer to not use those (but if that is my only option, I would use them).
You could try this: http://sedodream.com/2010/10/22/MSBuildExtendingTheSolutionBuild.aspx
Unfortunately it only works called from the command line via MSBuild. Seems to be a design flaw that the behaviour is different and these events are not available via the IDE.
You could also modify your base MSBuild tasks to include the action based on a specific flag/file existence/solution name, but this is all sorts of evil.
Otherwise, you are pretty stuck with a prebuild on each project.
I call nuget install from the prebuild event for any project that uses nuget packages. It is smart enough to only download packages that have not already been downloaded.