A very small portion of our codebase is some legacy Java code. I'm trying to add a new build that would invoke ant to build this project.
The first problem is that TFS doesn't allow you to create a build that doesn't build a .Net solution. I got around this by copying a previous build file and adding an EndToEndIteration task which is the entry point for the build.
The problem is that none of the usual build variables are populated - $(BuildDirectory), $(SolutionRoot) - all 开发者_运维知识库blank. This pretty much means I can't invoke my ant task without hardcoding the paths (which I definitely can't do).
Any ideas?
You may want to take a look at Teamprise Build Extensions which allows building Ant or Maven tasks from TFS.
- If you don't already have one, create a task that will store and retrieve environment variables, you're definitely going to need them doing anything java related (I believe there is one in the MSBuild extension pack)
- Create a custom task to wrap Ant or use the Script task from the MSBuild Community Tasks collection
- Run it a million times and fix the problems as you go, it's usually easier and faster to do this from the command line, so make friends with msbuild.exe inside the terminal
You should be able to pass around any info you want between environment variables, making whatever you want to do possible. I'm not going to recommend hard-coding paths to you, but you have to put the config somewhere and it's all a trade off of what you want to change and how you want things organized. If you really need to, you can push all the config into a database and suck it down with one of the SQL tasks in the above links, but just remember you're adding a considerable amount of complexity that may be unnecessary.
Ask yourself:
- how often is this value likely to change?
- what is the full set of tasks that would need to be done if it changes?
Write the answers to that down somewhere and make sure everybody on the team understands it. When it comes to build systems in my opinion "less is more". Find the simplest way to do it, and do that until that becomes unacceptable and only then add complexity... TFS is complicated enough already.
I think you are using the wrong tool for the job here - TFS will never be a good solution for building any other than .NET applications. I think you are better off just using ant in a standalone capacity.
Thanks for all the answers.
In the end I resorted to including an empty solution next to the build file. This way all the variables are populated and I simply included a which did everything I wanted.
精彩评论