Help with my team build project
I setup a build using team build and it created and xml file called TFSBuild.proj. My solution has several web projects and several other projects to which my web projects refer...such as my data layer, my file handling layer, etc... When I run the build it puts all of the .dlls into one folder called "release" and all of the code it pulled out of the source repository into a folder called "source". I would like it if after the build I had all of the code and referenced .dll's in a useful places, with the proper projects, ready for deployment.
ok - lets say my first web project in my solution is called website, and it references several .dll's in the solution.
I guess I could copy the code I want from the source folder, because it's the latest version, but that doesn't have the needed referenced .dll's, so then I could go to the "release" folder and get the needed .dll's. But if I hard code the copy command, then what if the references change? How can I just get the .dll's I need into a folder called bin in the folder with the other web stuff I want to release? Also, I would like to just get certain files, that I would put on my web servers, not all of the project files and other things I don't need. Thanks for any help you can give!
Thanks
<ProjectDefaultTargets="DesktopBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportProject="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\TeamBuild\Microsoft.TeamFoundation.Build.targets"/>
<ProjectExtensions>
<BuildMachine>appdev</BuildMachine>
</ProjectExtensions>
<PropertyGroup>
<TeamProject>MILeg</TeamProject>
<BuildDirectoryPath>D:\mileg\tfs\build</BuildDirectoryPath>
<DropLocation>\\appdev\drop</DropLocation>
<RunTest>false</RunTest>
<WorkItemFieldValues>Symptom=build break;Steps To Reproduce=Start the build using Team Build</WorkItemFieldValues>
<RunCodeAnalysis>Never</RunCodeAnalysis>
<UpdateAssociatedWorkItems>true</UpdateAssociatedWorkItems>
<WorkItemTitle>Build failure in build:</WorkItemTitle>
<DescriptionText>This work item was created by Team Build on a build failure.</DescriptionText>
<BuildlogText>The build log file is at:</BuildlogText>
<ErrorWarningLogText>The errors/warnings log file is at:</ErrorWarningLogText>
</PropertyGroup>
<ItemGroup>
<SolutionToBuildInclude="$(SolutionRoot)\MILeg.sln"/>
</ItemGroup>
<ItemGroup>
<ConfigurationToBuildInclude="Release|Any CPU">
<FlavorToBuild>Release</FlavorToBuild>
<PlatformToBuild>Any CPU</PlatformToBuild>
</ConfigurationToBuild>
</ItemGroup>
<ItemGroup>
<MetaDataFileInclude=" ">
<TestList>
</TestList>
</MetaDataFile>
</ItemGroup>
<ItemGroup>
</ItemGroup>
</Project>
When the Team Build runs, it creates 3 folders, Sources ( for the source code to build, BuildType (for the TeamBuild files) and Binaries (for the output dlls and support files). The Binaries folder is where all of the files that you need are placed. There is a subfolder in Binaries named for your configuration, usually Release. This folder contains all of your support assemblies. There is also a sub-folder in here called _PublishedWebSites which contains all of the output for your web projects. Between the Release and _PublishedWebSites folders, you should have everything you need to copy out to get your site to run.
To copy these files to another location, you can override the AfterCompile target. Here is a code snippet that will copy the files to the location in the Destination property. You will have to tweak it for your particular situation, but it will copy the DLLs from Release to Destination and copy all the files recursively from _PublishedWebSites\MyWebSite to Destination
1: <PropertyGroup> 2: <Destination>C:\SomePath</Destination> 3: </PropertyGroup> 4: 5: <Target Name="AfterCompile"> 6: 7: <CreateItem Include="$(BinariesRoot)\Release\_PublishedWebSites\MyWebSite\**\*"> 8: <Output ItemName="MyWebSite" TaskParameter="Include" /> 9: </CreateItem> 10: 11: <CreateItem Include="$(BinariesRoot)\Release\*.dll"> 12: <Output ItemName="MyDLLs" TaskParameter="Include" /> 13: </CreateItem> 14: 15: <Copy SourceFiles="@(MyWebSite)" DestinationFolder="$(Destination)\%(RecursiveDir)" /> 16: <Copy SourceFiles="@(MyDLLs)" DestinationFolder="$(Destination)\%(RecursiveDir)" /> 17: </Target>
- Steve
Steve,
Thanks so much for your help! This is very useful. One thing though...I have a release folder under the binaries folder, but it is a flat list of all the binaries. I wish I did have the _PublishedWebSites subdirectory, but alas, I have none. I do have "release" folders under the regular class libraries under source rather than under binaries, but these seem to only contain the .dll for that class, not all the dependencies, like I would have in the bin folder after a normal build.
Any idea why I would not have the "PublishedWebSites subdirectory that you mention?
Thqanks again!
Jenny
Jenny,
I'm not sure why you don't have it although I can guess that it is because I am using the Web Application Project for my web services. The Web Applicatoin project comes with an additional .targets file that the project file Imports. That targets file must be the one that creates the _PublishedWebsites folder and copies all of the files to it. Since WebSite projects don't have a project file, they can't benefit from this kind of "project file augmentation".
I'm curious, do you need to use Web Site projects or would Web App projects work for you? We mode away from Web Site projects for our web services because we think they suck. I hate not having a project file and having to use stupid .refresh files for my references.
So if you can get into Web App projects, your life will get easier and you'll be able to eradicate world hunger to boot! (Ok, that world hunger part is bogus, but you get my drift)
- Steve
Steve,
We chose to try the web site project because it's the 'new' way to do it, so we though this must be the better way :-> I'm not sure yet why...but we have not had too much trouble with it so far.
I discovered that my solution was set to compile as a .NET application (I think that's what it was set to-been a few days since I looked at this) even though I had web sites, which means I should have had the build set to compile in "Mixed Platform" mode. Also, there were some issues with the paths and source control, which changing the path to ./ seemed to fix. Read more about that here...
http://msdn.microsoft.com/vstudio/teamsystem/reference/technotes/team_build/build_asp_proj.aspx
Thanks for your help!
Jenny
Jenny,
Just wanted to write back with an interesting anecdote about the web site project. I was at the Patterns & Practices Summit in Redmond last week. During one of the presentations, the speaker asked how many people were using the web site project vs. the web application project. Of the roughly 250 people in attendance, about 80% were using the web application project. The main reason was that you get all of the benefits of the web site project, most notably the Cassini personal web server, while maintaining a file format (*proj files) that is well known and understood.
- Steve