VSTS Build not generating latest bin binaries - tfs

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

Related

TFS programatically find and use files from last build

I am new to TFS. I have two builds on TFS, one is the main solution which spills out .exe files, the other a Wix installer solution that grabs files from the main solution. Right now I use a temp file folder and post/pre build events to receive/feed these .exe files.
Can I streamline this process on TFS? I'd like the installer to
Main solution generates a meaningful file path for each build, ideally related to build number.
Installer solution can find file path of the last successful build of main solution programmatically.
Make this file path available as a build variable or something so it knows where to grab files when building.

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 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

Preventing Checkin to trigger multiple Build with TFS 2010

I have some Libraries added in my TFS 2010 project in a Lib folder.
Each time I check In a dll in the Lib folder, all the build that reference that Lib folder trig automatically (more than 20 Build).
I can use the ***NO_CI*** to prevent that. But I prefer to have something automatic.
Is it possible to have an event handler on TFS to prevent that.
Ex. If the check in is on that folder, do not scan all the CI Build Workspaces to trig the build.
The workspace mapping in the build definitions defines which files/folders are part of that build. You can use cloaked folders to explicitly exclude folders from the workspace.
However, the workspace mapping is used for 2 purposes: to determine which files get downloaded to the build server as part of the build, and to determine which files trigger CI/Rolling/Gated builds.
If you exclude folders from the workspace (e.g. using cloaked folders) it will stop the builds from being triggered but it will also stop those files from being downloaded as part of the build.
If you want to have a build download a certain folder as part of the build but not have builds triggered by check-ins to that folder I don't believe it is possible without customizing the build workflow.
When you include a folder in a workspace, you're saying that changes to that folder affect your project. This is the same for changes to shared source code as for shared binary. If it changes, then the affected applications should be built (and their automated tests should be run) so taht it can be determined whether the changed files have broken anything.
Make sure each library in the lib folder has it's own folder + version folders beneath
lib
EntityFramework
4.1
EntityFramework.dll
4.2
EntityFramework.dll
Then modify your builds to only reference specific folders for the library a project references.
It takes a lot of work to setup builds, but will ensure the build only triggers when a file needed for the build is changed.
Alternatively a copy of each library in the projects directory, which you could manage with a package manager like NuGet or OpenWrap

Resources