Discover errors in your .NET app you never knew were happening and use detailed error reports to squash them with ease. Make your app Exceptionless!
Sign up for FREE!
I'm attempting to automate my build for a solution that has a project that gets generated by codesmith. I'm trying to figure out how to get my files to generate as part of the automated build.
Some background on me... I'm completely new to doing automated builds in TFS. The way I have set this up so far is I created a new build definition by going to Team Explorer clicking on Builds and "New Build Definition". This has a basic UI for setting up a build. I understand all of this, but that is as complex as i've gotten.
Any guidance on what I need to do here to tie in codesmith? I have found the following link, but I don't know how that ties in to what i'm doing. Please help me bridge the gap if possible.
My apologies for any confusion, from the links you had sent me I thought that you were wanting to manually update a projects (.proj / .csproj) for generation from TFS. However, there is a much easier way to accomplish this.
In your Visual Studio Project, please right click on your CodeSmith Generator Project file and select Generate On Build. This will tell Generator to generate anytime the project builds (including on the build server) and configure everything for you. Here is a link that outlines this process.
I also talked with the team, and we are going to spend some time reviewing our Build Server documentation / processes and ensure the most painless experience possible.
Please let us know if you have any questions.
CodeSmith Tools, LLC. Software Development Engineer
.NetTiers team | Visit http://www.nettiers.net
I'm using CodeSmith 5 and don't have the option to updgrade at the moment.
You would need to open up your msbuild project file and add the statement for importing the targets file. Then you would need to add a new ItemGroup with a Generate Node that has a filepath to your Generator Project File. Then when the build runs, it will generate using CodeSmith Generator.
I'm assuming i need to install CodeSmith on the BuildServer correct? Which account does it need to run under? TFSService?
Also, Dumb question... How do you open a "Build Project"? I have a Build Definition, but I don't see a project file.
Yes, you would need to install CodeSmith Generator on the build server and activate using the same user that the TFS Service uses.
Do you have a master project file (.proj) file that tfs executes? This file would contain all of your build targets.. This would be the file you would need to open and update accordingly.
I've installed Codesmith on the server. I'm still not sure what you mean by master project file.
As stated initially, I have a Solution and some class library projects. I then create a build definition. I'm not sure what a master project is. Could you point me to some link anywhere explaining this concept in visual studio 2010.
The following link shows what I'm working with.
I appreciate the help.
I see in the following article that they talk about a project file
It says "1.Click the Project File tab". I don't see a "Project File Tab".
ahhh.. gotcha. I should have thought of that. We turned that off in the past when we were learning the tool. I'll re-enable and give it a shot. Thanks for your patience. I'll report back in a day or two with feedback.
Last question... I'm sure there isn't an elegant solution for this, but I figured I could ask. We turn the generate on build option to off for our day to day work. We generate alot of classes so our main person in charge of generation likes to keep it this way. Obviously I need to turn this on for the automated builds. Is there a good way to dynamically change this before the automated build kicks-off? I imagine no, but you never know.
I've update my csp as you stated and it looks like that will work. I'm now running into the issuean issue that I can't figure out. When my buildserver does a build it fails with the following error.
C:\Program Files (x86)\MSBuild\CodeSmith\CodeSmith.targets (35): The "CodeSmith.MSBuild.CodeSmith" task could not be loaded from the assembly CodeSmith.MSBuild.v4.0, Version=126.96.36.199, Culture=neutral, PublicKeyToken=9fd61cdb91609a7a. Could not load file or assembly 'CodeSmith.MSBuild.v4.0, Version=188.8.131.52, Culture=neutral, PublicKeyToken=9fd61cdb91609a7a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
I have CodesSmith installed and I believe it is registered under the same account the Build Service is using. Is there an easy way to check this out? Thanks again.
I'm pretty sure the following will work but I haven't tried it. We do something similar to this internally... You could set up a build conditional for generating the csp on build. Basically you would need to move the CSP's Item node to an ItemGroup inside of the .csproj file and then set a negate condition (social.msdn.microsoft.com/.../3f485bf4-1b00-48bf-b5d0-4b83341ce4a6). I'm not sure if you can pass in DefineConstants (Compiler Directives) during the build process but I would think you can.
It looks like one of the assemblies can't be loaded. On the build machine, what features did you install with CodeSmith Generator? What versions of .NET are installed on the box? If you login as the build user can you manually run the build process?
I just did the default install of CodeSmith on the build server. If I navigat to the path "C:\Program Files (x86)\MSBuild\CodeSmith\CodeSmith.targets " it does exist.
We have .Net 4.0 on the server. I don't, however, have Visual Studio installed on this machine, just the TFS 2010 build server piece. Do you think that is the culprit?
This is the first time we setup a new build server. All it has on ir really is TFS Build, CodeSmith, and a few other things. Like stated above, I'm learning as I go. :)