TFS Build Definition: prevent copy DLL to drop folder - tfs

We use TFS 2012 Build server for our Web Project
Build result is copied into folder _PublishedWebsites of Build drop folder
_PublishedWebsites contains all we need to deploy site later
But all DLL existing in _PublishedWebsites are repeated in the drop folder as well.
So we have in drop folder:
_PublishedWebsites
Bin
WebSiteLibrary1.Dll
WebSiteLibrary2.Dll
WebSiteLibrary3.Dll
logs
WebSiteLibrary1.Dll
WebSiteLibrary2.Dll
WebSiteLibrary3.Dll
How to configure Build Definition dll be copied only to _PublishedWebsites ?

You must customize the Build Template: or you tweak the final Copy to Drop Destination, but it could be easier to add a Delete files after that Activity, even if it is slower.
Please, check the names.

Related

VSTS Build not generating latest bin binaries

I am using TFS 2018 CI pipeline for MVC project, also I added the project's bin files into the TFS, there is no problem with the pipeline, its getting succeeded and artifact is generated successfully but the main problem is that if I made any changes in code related to project's DLL,
the CI pipeline's build solution not generating its own latest bin file
Until or unless I manually check Out the project.dll file and than check In the file than pipeline will pick the changes, what I am missing, same result by using 'MSBUILD' tasks, I also TICK clean the 'all directories' but same result
After spending whole day I came to the solution that, bin folder should not be added/included into the Source Control (TFS/Azure),
bin folder or project's binaries should not be added in to TFS
bin folder should be excluded in the project, after doing this operation, when I run the same build pipeline and inspect the artifact found that TFS builds added the bin folder and files accordingly, thats shocked me.
One thing should be remember in this case that what about external dlls reference, create a CommonDLLs folder at the same level of the src folder and put all external DLLs there. They are referenced through a relative path

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:

TFS 2015 VNext Copy Files task without copying folders

Using the copy task to copy some msi files to the drop location. The msis are in corresponding bin/debug/release folders. When I use the copy files task it copies the entire folder structure (bin/debug/...msi) to the target location. I just want it to copy the files to the target location. Is that possible?
This can be achieved. However, you need to specify the copy root if you want to copy files only without folder structure. You can use $(Build.StagingDirectory) as a target for this. Afterwards use the Publish task with $(Build.StagingDirectory) as copy root and publish everything from this root to the drop.
Detail step and screenshot please take a look at the answer from Eddie in this question: Copy one file in target directory on deploy from visual studio team services

TFS Build Template Copy Directory and Exclusion of files

I have TFS Build Default Template and I added to it, between "Run on Agent' and "Check In Gated Changes for CheckInShelveset Builds", Copy Directory with Source BuildDetail.DropLocation and destination a shared directory on a server.
My problem comes that the Copy Directory is not executed or is executed, but no files are copied.
I am not sure if this is the right location to place this activity, but as I read the tutorial in msdn it seems correct. How can I force the built version of the web site be copied in a specific directory, and on a separate note is there a way to exclude some files from the copy? I wish to copy the built web site without copying the web.config file.
You can use copy activity which OOB and also if you use TFS 2013 default template it has post build activity which can run powershell

Resources