VS Team Services Project Dependency Build - asp.net-mvc

I am new to Team Services (web based) build process. I have a Solution 1 with Project A and B where B is dependent on A (common code). Project A is under a different Solution 2 but was added to Solution 1 via "Add...Existing Project". Both solutions and projects are under TS source control. When I checked in Project B, Team Services build process could not find Project A and the build failed. How do I link Project A to the build process for Solution 1/Project B? Is there a better way to solve this? Thanks!

You need to keep the folders’ structure, for example:
Open solution file through NotePad and check the path of Project A (e.g. ..\solution1\ProjectA\ProjectA.csproj)
Edit your build definition add Project A in workspace mapping (Get sources), for example:
(Server path=>local path)
[solution 2 server path] => solution2
[solution 1 server path] => solution1

Related

TFS Devops. Can not find the external project file

I have a c# solution with external project added. This external project is in another TFS Project, then when I generate the build, TFS show next error
"Error MSB3202: The project file can not be found "...csproj".
In the GetSource step (Before Agent Job), i can't add this project because it's in another TFS Project.
The structure is like this:
TFS Collection
... TFS Project Main
... Branch 1
... Solution 1
... TFS Another Project
... Branch 2
... Solution 2
Solution 2 has Project 2.
Solution 1 has Project 1 and add Existing Project 2.
Is it possible build Solution 1 in TFS Devops?
I work with Visual Studio 2015 and TFS 2018.
Thanks so much.
When you select the sources in the build definition on Project 1 you can select the files from Project 2 (even if it's a different TFS project):
Now in the build agent you have both projects and you can build all.

Load dependencies in Jenkins

I am using Jenkins for building a few Java projects. I've come across a puzzle that I can't quite figure out: I have two projects, Project A and Project B. Project B depends on having A as a library. I don't want to build A before B. I want B to find the latest, promoted Project A.jar and copy it to a folder in the Project B workspace. What's the best way to go about this?
You can configure Jenkins to add a post build step to archive artifacts (your JAR file in this case)
Then use the copy artifact plugin in your second project to fetch the artifact https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin

Linked file in WCF RIA service does not build in TFS Build server

I've just setup a TFS (2012) server and now I'm trying to build the complete code (written in .NET 4.0 in VS 2010) via the TFS Build server. But in my solutions I have also a WCF RIA project which contains linked files because they are used somewhere else also and there is no possibility to add a reference to a general .NET binary in WCF/Silverlight.
Everything builds without any problem on my development machine but when I check it all in, create a standard build definition and run that build definition I get the following problem. The linked files have usings (UsingNamespace for example) to other projects that are also build by us and build before the WCF/Silverlight but the following error pops up while building through TFS Build server:
The type or namespace 'UsingNamespace' could not be found (are you
missing a using directive or an assembly reference?)'
Is there any solution for this problem that I looked over?
EDIT 1
Just tried to set the Copy to Output Directory propertie of the linked files to Copy Always but this still gives me the same error as I was expecting. The problem is that the linked file is placed somewhere that it can use the usings but the WCF RIA service cannot access/find that using.
EDIT 2
Just tried out my local test TFS where I can do what I want and there I made a build definition with just the solutions needed to make that the project with the linked files builds. This worked without any problem. Then I tried the same on our TFS server with a new build definition that has the same solutions as on my test TFS and here it did not work. The only difference that I know for sure is that my test TFS is TFS 2012 Update 1 and that my production TFS does not have the update 1 yet. I'll try to install it next week.
EDIT 3
I've just updated our production TFS to Update 1 but it is still not working with my temporary build definition which only contains the projects that are needed to build the silverlight application with the linked files. The 2 workspaces are the same on both server and the projects to build are also the same.
You need to specify the workspace information in the Build Definition for the build to use. The workspaces are what the build process copies from source control to the build server. If you don't have everything in the build server's workspace, it can't build properly.
The Source Control Folder in the workspace tab is the location of the files you need from TFS. The Build Agent Folder is a relative path from the build server's pre-defined base location. You'll usually use $(SourceDir)\Folder to specify the "Folder" that your build process needs.
This sounds like an $(Outdir) problem. A build definition in TFS automatically overrides the Bin folder. All Binaries are redirected to the bin folder upon compile. Sounds to me that you are using a mixture of project references and file references. The file references are probably what is causing your build failures.
Example if you compile in the same build the following solutions
Solution1.sln (TFS Build Pass)
project1.csproj
project2.csproj (references project 1)
Solution2.sln (TFS Build Failure)
project3.csproj (references binary output of project 1)
Expectations from TFS out of the box without customizing your workflow is that this simple build will fail. The reason is that in your development box all projects produce output to one destination while in a tfs build your projects will build to $(Outdir).
Some Things to try
Simple (best practice in my view)
Create 1 solution and use project references instead of file references.
Complex
Build using MSBuild project files
Modify your windows workflow to not override the $(Outdir)
Copy the binaries after a build is complete.
Best practice on Automating Builds
Build from command line
Build from cmd a NON vs2010 command line.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe FullpathtoSolutionFile.sln
Cheers!
Apparently there was just missing the WCF RIA services V1.0 SP2 on the TFS server. If that was installed the problem was solved.

How do I copy dll files for a build using team build

I have a bunch of external dlls I use in multiple projects. These dlls are referenced by these projects and everything compiles fine.
Now I am trying to get a Team Foundation Server build going for my projects. When I run the build, it complains that it can't find the needed files. How do I get TFS to find the needed files?
I was thinking I could use the copydirectory windows workflow function in a custom build template but I'm not sure if this is the right way to do things. Also, if I do use copydirectory, how do I reference directories that reside on TFS rather than on the file system? And where do I copy the files to?
Try this:(if using 2010)
At the Workspaces tab you can map the folder that has all the DLLs you want, just make sure you reference the assemblies in your project appropriately.
For instance, if your project is referring to the assemblies one level UP, before the project root folder, you may set the workspace like below:
$\Team Project\src -> $(BuildDirectory)\src
$\Team Project\dlls -> $(BuildDirectory)
Something like that should solve your issue.
There's also a way to do it in VS2010 build: You should add a copy command to the prebuild step for the project (select the project -> Properties -> Build Events).
If you want to use the windows workflow - template method, refer to this guide: http://blogs.msdn.com/b/buckh/archive/2010/01/21/deep-dive-on-windows-workflow-4-0-activities.aspx

Team Foundation server project template

When we create a project in TFS, we always follow these steps:
1) Create new team project
2) Create workspace, assocate to source control folder and local folder
3) Create three folders under team project (Main, Dev, Release)
4) Check in source to Main
5) Convert Main to branch
6) Create Dev/Dev and Release/Release branches from Main branch
These 6 steps are pretty much stock for every project we build, but it is possible for developers to get it wrong or stray from this design. Is there something available for TFS that we can use to automate this process?
You can create a new team project with the "tfpt createteamproject" (from the power tools). You can also execute all your tasks from the command line to (use the tf and the tfpt commands).
In your case, creating a batch file that executes all these commands could be your solution

Resources