How to include asp.net assets when using Team Build 2008 - tfs

I am able to configure our Build Server (Team Build 2008) to build our asp.net application. I've done so via
<ConfigurationToBuild Include="Debug|Mixed Platforms">
<FlavorToBuild>Debug</FlavorToBuild>
<PlatformToBuild>Mixed Platforms</PlatformToBuild>
</ConfigurationToBuild>
Problem though, the asp.net assets(eg. script folders, imgs, etc.) are not copied to the deployment folder. Folder(_PublishedWebsites) only contains the binaries references of the app plus the pre-compiled web services.
Is there a way to include said folders/files to the deployment folder?
Thanks
Note: Using Website Projects (WSP)

I was able to make this work, and factors included the way our project was checked in to our source control.
Since we're using WSP, the assemblies refrenced are copied to the bin folder, unfortunately devs checked everything in (including this) and TFS cannot overwrite the same files since TFS marked everyfile(not for edit) as read only. The resolution is to remove those .DLLs in the bin and just check in the .refresh files and let the compiler copy the actual .DLLS to the bin.
The aspnet_compiler has problems with WSP as it works well with project files(ie WAP) and that the references of physical(debug/release) of the sln file confuses it (eg ......\webappfolder). The resolution is to make(hand editing the sln file) the Debug.AspNetCompiler.PhysicalPath and Release.AspNetCompiler.PhysicalPath point to ".\webappfolder\" instead of the previous so that aspnet_compiler will be able to actually go to that folder and compile.
Make sure in the tfsbuild.proj you have the same setting (depending on the release or debug) above

Related

Can we create TFS build definition of website without .proj file

I am using TFS 2015 for creating builds of application. I am able to create build template for web application as web application have both .sln and .proj.
But for Websites, I only have .sln file and no .proj.
How can I create Build definition in TFS 2015 for website having only .sln file?
As #Cece said, the answer is yes, you can run the MSBuild on the server without a .csproj.
I am assuming that your project is not running on the final version of the .Net Framework. In your case I suggest you to make this change
https://stackoverflow.com/a/42493822/819153
Then you should copy all the files from the PrecompiledWeb folder, and there you should find your .sln
Sometimes there are vb/cs projects that I have seen that they do not come with a project file, csproj or vbproject. They run with the .NET Framework 2.0. For those, you can create a build definition just to compile the .sln, but when you deploy the application, you need to copy the entire PrecompiledWeb folder to the IIS folder on your server. Try to add the task that has the option copy and publish and put all the changes to your server.
Check the privilege of the folder where you want to put the files, and be sure that the agent that is running the builds on the TFS has access READ/WRITE access to the server folder.
In your case, please check the .sln file, inside of it you should have a TargetPath, by default is PrecompiledWeb, but sometimes when you run the msbuild on the tfs you end with an error saying that the PrecompiledWeb can't be on the same tree of your solution, what you need to do then is putting a level up of your solution folder
Debug.AspNetCompiler.TargetPath = "..\..\PrecompiledWeb\YourProject"
Then on your CopyTask you need to change the CopyRoot directory, if you made any transformation before your build step to the webconfig, those transformations will be reflected on the PrecomiledWeb\YourProject. All the files in that folder should be deployed to the server folder path.
Lets say that you have this structure in your Branch
Branch/MyProject, then after you compile the source code on the TFS, your precompiled folder will be stored at the same level of your project on the agents folder. Please see the picture below to get the idea how to copy the files from the PrecompiledWeb.
The answer is Yes. You can create a build definition for a WebSite project by specifying the .sln file.

TFS build modifying website folder structure

In my solution I have a basic ASP.NET MVC website and a Wix Project. To identify the files that need installed I'm using Heat (a Wix component) to index the build output. This is part of a post-build event. It works perfectly on my local machine when building in Visual Studio 2015.
My problem occurs when checked-in and the CI (TFS Build) builds it. The differences are:
The contents of the bin folder is placed directly in the build folder
The rest of the website is placed under a new _PublishedWebsites folder
This means many of the references get broken. For example when dropping the _PublishedWebsites folder into IIS breaks (as .net cannot locate the contents of Bin)
After much research on the subject, and many attempts to pass MSBuild parameters, I'm reaching the end of my efforts.
Is there a way for a build in TFS to leave file locations intact without copying and creating new folders?
If not what is the recommended way to get a deployment ready site (in a single folder) from TFS?
Adding a Copy Files task to copy bin folder to $(build.artifactstagingdirectory)\_PublishedWebsites, check the screenshot below:

Choose what goes to drop folder of TFS build

I have a drop folder created by TFS build which contains all the produced artifacts:
.dll \ .config \ .pdb files from all projects
_PublishedWebsites folder
*.msi files produces by Wix projects
All I really care about is *.msi files as everything I deploy is in them.
How can I specify for the TFS build not to bother with all the other files in the Drop folder?
I know I can customize the build to delete files after the solution build, but maybe there is a clever way of disabling them at all?
Personally I use named platforms such as Application and Setup in my SLNs so that when TFS archives the drop folder one class of files goes into one directory structure and another class of files goes into another. This way it's easy to find the MSI and it's also easy to see what the application code looked like before then. (Perhaps the contents of a web.config or an HTML that was added to the application sln but not the installer sln.
IF you want to suppress the application sln from archiving you have to look at that. It's not an MSI / WiX thing.
If you are using TFS 2013 (or VSO) you can easily have a PowerShell executed post build to do whatever clean up and rearranging you need.
Note: The build used the files in the root to do testing, code analysis, test impact analysis, and other automatic actions. Make sure that you only remove files after all of the checks. A better idea is to leave the files be and just push theb*.msi files to a "/_PublishedApplications/* folder.
There is a PublishedApplication Nuget package that can make this easyer. Take a look...
If you are using TFS 2010/2012 you can use the "TFS Community Build Tools" to call PowerShell and do other things.

TFSBuild 2010 Package only contains sources - not binaries

The packages created by a TFS 2010 Build only contain our Sources, not the binaries. When this is (automatically) deployed to IIS, the site does not run because it is missing DLLs that are created during the build process.
We have a Web Project created in VS2010. If I select "Build Deployment Package" from a right click in VS we get a zip file in the obj\Release\Package folder that contains the fully build site.
However, if ask our TFS build process to create the package by adding "/p:CreatePackageOnPublish=true /p:DeployOnBuild=true" to the MSBuild arguments (as advised in amongst other places here) we get an zip file in _PublishedWebsites\_Package\.zip that only contains the sources.
My best guess is that the CopyAllFilesToSingleFolderForPackage is picking up the files from the wrong place.
I notice a similar issue asked here - TFS 2010 and creating a package - although his workaround in not appropriate in many cases, I'd guess.
My concern is that this is using a built-in, but poorly documented feature of MSBuild/TFS so when it doesn't work you're a little in the wilderness.
It seems that deployOnBuild runs some "package"-like target on each of the projects. If you have built the projects into a separate directory (which the default TFS 2010 build does by default) the packaging won't pick up the compiled files.
One solution is to get rid of the custom output folder for the MSBuild Command within the TFS build workflow. This will cause the compiled files to be located in-situ and be included in the package.
Now the rest of the TFS workflow is require some changes because it'll be expecting to transfer the files from the output directory, and they won't be there.

What files do I need to deploy for ASP.NET mvc?

I know I can just copy all of my files from my development environment into my live website directory, but then I know I'm copying several files that aren't necessary (e.g. the .sln file and .csproj files).
What files actually have to be copied for ASP.NET MVC web applications to run? (E.g. Do I need to copy all .CS files?)
If you develop in Microsoft Visual Studio, you can use the Build > Publish option (when you're in the context of an ASP.NET MVC project) and publish it directly.
If you cannot use this and have to do a copy all you need is anything that ISN'T a .cs file (views, .config files etc) and your compiled ASP.NET MVC site's .dll (ex MvcApplication1.dll). If you want to get an idea of what you need use the Build > Publish tool to a local directory and take a look at what's in there.
You don't need solution or project files.
Using the Build / Publish approach is the best to ensure you have the files you need. Before building though, if you don't have ASP.NET 3.5 SP1 installed on your server, make sure you go into the references in your project for the following assemblies and set the to "Copy Local" in each of their respective property pages.
System.Web.MVC
System.Web.Routing
System.Web.Abstractions
This will make sure that each of these assemblies is copied to your "bin" folder on the published site.
Brian
After you compile your project, you shouldn't copy all .cs files.
Take a look at this link.
Basically everything but the views get compiled into a dll. You can use the deploy option to see what you need to deploy ;).

Resources