Developing in Visual Studio but using custom, non-msbuild build scripts - visual-studio

I'd like to start exploring options outside of msbuild for scripting my builds, like CAKE or FAKE.
What's the best practice for developing .NET Core in Visual Studio but using external build scripts? Like, how does this actually work in practice?
I'd like to continue to take full advantage of the VS environment, including Intellisense, package management, IDE features like Go To Definition, etc.
Do people somehow customize/override the VS F5 and/or Ctrl-Shift-B behaviors? Or do they use .csproj files and let VS and msbuild do its own thing until it's time to generate a "real" build, and then run their own scripts at that time?

Locally on your development machine you usually run build scripts from command line. You don't write build script to help you while developing. You write them that your code is verified by an automated build and that you automate processes like creating deployment packages, publishing nuget packages...
Most common practice is contionous integration approach. This means that when you or someone in your team commits/pushes code to the version control system(like git svn...) your selected continuous integration tool (like jenkins, team city...) pulls source code from version control system and runs your build script which for example compiles your code, run tests, creates deployment package.
I would also suggest that you take a look at flubu. Flubu is a cross platform build automation tool for building projects and executing deployment scripts using C# code. It's easy to learn beacuse you write your build script entirely in c#.
More about flubu can be readed here: https://stackoverflow.com/a/46776658/3118784

Related

How can I consistently automate, using TFS vNext build steps, building whatever solution files our development teams get working using Visual Studio?

Developers use the Visual Studio (VS) GUI to develop their solutions and get their projects all building using a solution file (.SLN). The build teams using vNext then have to automate those builds using MSBuild instead of devenv.exe (the Visual Studio executable file). This is a serious and chronic problem because not only is MSBuild incapable of building several project types, but the build order is defined in a completely different, and complex, way.
Some Microsoft advice (https://learn.microsoft.com/en-us/archive/blogs/msbuild/incorrect-solution-build-ordering-when-using-msbuild-exe) is to switch to explicit dependencies in each .*proj file and remove all dependency specifications in the .SLN file. This sounds like a person who has never worked in a relatively powerless build team trying to get development teams to:
do a lot of what they perceive as time-wasting extra work and to
change how they do things
What build teams need is a way to automate whatever VS allows dev teams to build. If VS is given a SLN to build, then a vNext build needs to be able to use that same SLN in the same way. Instead vNext currently only offers MSBuild as the build tool. MSBuild has many more options than devenv, so that would be great, IF it could be made to use the SLN to govern dependencies in the same way as VS, and would be upgraded to build all the same project types.
There have been prospective efforts, referenced by PatrickLu-MSFT at Build project using devenv.exe in TFS 15RC1 Build Server, to enhance a vNext build step to allow devenv to be used instead of MSBuild, but those efforts seem to have been dropped.
Maybe someone has developed a custom vNext build step to build using devenv?
Here is an existing extension you can reference, which provides a build task in your TFS/VSTS instance that will allow you to build your projects using DevEnv.com (Visual Studio):
https://marketplace.visualstudio.com/items?itemName=mmajcica.devenv-build
If you want to automatically use TFS/DevOps build whatever solution files our development teams get working using Visual Studio, you could set CI trigger in build pipeline, when the solution build successfully on local, you can check in/commit the changes, and trigger TFS/DevOps builds.

NSIS installer script with TFS Build Tool

is it possible to utilize my NSIS installer script to make an automated build (daily) for my program in TFS 2010? The program isnt C#, it's actually small talk, so the installer being designed in NSIS was prior to our group being required to migrate source control into TFS.
Essentially the installer just copy/pastes the directory and shortcuts onto destination PC, and runs a regedit for the new parameters. I noted in the TFS build tool (which I'm extremely unfamiliar with) that it constantly wants me to point at a .proj file.. Does this mean I've got to convert our NSIS scripts into some .NET equivalent (if so how?) or is there a plugin of some sort to allow these guys to play nice together?
If your project support MSBuild to build it, you can use TFS Team Build directly. If your project doesn’t support MSBuild to build it, you need to provide a compiler which can build your project, and this compiler support run the command line to invoke it, so we can add the InvokeProcess activity(execute the command line) to invoke that compiler to build your project in build process template.
Here are useful blogs for your reference:
http://donovanbrown.com/post/I-need-to-build-a-project-that-is-not-supported-by-MSBuild
http://blogs.objectsharp.com/post/2011/03/31/TFS-Build-Invoke-Process-Activity.aspx

What is Manual Build?

Seems like a pretty obvious question but I haven't been able to find this anywhere online - but what exactly counts as building something manually? As in if I do Ctrl+Shift+B on Visual Studio is that manually building? Then how could I go from that to automated build (running it from command line?). All I know is that I am supposed to use MSBuild to do automated builds on a project that is currently built 'manually'.
What is Manual Build?
Whether you are using Visual Studio or MSBuild command to build is considered to be manual build. That because you need to build your project manually every time no matter you are using Visual Studio or MSBuild command. And the hot key Ctrl+Shift+B is a quick start mode to build project in Visual Studio.
If you want to automated build, you should consider 'continuous integration' For example, TFS(Team Foundation Server), Teamcity, etc. You can easily search those continuous integration info on the internet.
The biggest difference between manual build and automated build is that you should manually build your project every time when source code changes, but automated build will execute the build automatically by continuous integration tool when source code changes, no need to build your project manually.

Can I add a Golang Compiler to Visual Studio Team Services

We are going to use Visual Studio Team Services for a project. We are using VSTS Git as our repository. A portion of this project is written in Golang. We want to enable CI and build/test all code at check in. I have been learning more about extensions, the build agents and build process within VSTS. I see in the marketplace there are options for Android, iOS and other platforms (but not GoLang). Can anyone start me on the path to creating a custom extension or build definition for Golang? How can I create a custom extension to enable automated builds at check-in of GoLang code? Thanks!
Yes but I would look at it a bit differently. There is no need to add anything to VSTS, you just need golang/the go compiler installed on your build agent and then you can set up a job using MSBuild like any other MSFT supported language which invokes the Go compiler with your sources. Basically, write an msbuild script who's sole job is to invoke the go compiler with the target sources.
Here are MSBuild docs on the Exec task which is what you'd use to kick off your build; https://msdn.microsoft.com/en-us/library/x8zx72cd.aspx
As far as I know in order to add the Go compiler you need to setup a private agent or install it on the fly using a build task like the tool installer

Automated release script and Visual Studio Setup projects

I think most people here understand the importance of fully automated builds.
The problem is one of our project is now using an integrated Visual Studio Setup project (vdproj) and has recently been ported to Visual Studio 2008. Unfortunatly, those won't build in MSBuild and calling devenv.exe /build on 2008 just crashes, apparently it does that on all multi core computer (!!!). So now I have the choice to either rollback to .Net 2.0 and 2005 or simply ditch Visual Studio deployement, but first, I'd like a second opinion.
Anyone knows of another automated way to build a .vdproj that will not require us to open the IDE and click on stuff?
WiX was what I had in mind when saying we would ditch vdproj. Do you have any experience with it, good things, caveat?
The low cost solution is to switch to using ClickOnce, which you can automate using MSBuild. But if you still need to create a Windows Installer package, you will need to convert your project to WiX (pretty straight foward) and build that with your solution.
This will get you started:
Automate Releases With MSBuild And Windows Installer XML
I've used WiX a little bit before, and generally I found that it's great once you figure out what to do but there is a steep learning curve. If you spend a solid day going over the WiX tutorial you should be be able to get 80% of your setup working.
WiX Toolset Tutorial
I had the same requirement and ended up using what is suggested in these two links
David Williams Blog
MSDN article
Basically, since Team Build, by itself, will not build the setup projects for you, this approach has you add a new build step after the regular build is complete. This step fires off a second build by launching the devenv.exe. The IDE will build your setup files. The extra build is a bit costly but we only needed it for builds that were going to be pushed out. The Daily build at most would need this customization our CI build does not need to build setup files each time.
After that you execute some Copy commands, once again build steps that show up in your Team System build results, to move the setup files to a network share etc.
It feels a bit like a kluge at first, but it does work, it is also a full-fledged part of the automated build in Team System so it worked for my Continuous Integration goals.

Resources