I am trying to set up an automatic build.vnext process for TFS 2015. This build process contains one Visual Studio Build build step, in which a .nupkg package file is created in the build agent's bin/Debug and bin/Release directories.
I have a private NuGet-Server installed on the same server as the build agents are running on. I want to copy the generated .nupkg files from the bin-directories to my NuGet-Server's package-source-folder (say C:\Packages).
How can I do this with TFS 2015 Build.Vnext/Preview?
Edit:
I can easily copy all build output from the agents to the package folder by configuring the Visual Studio Build options "Copy to Staging Folder" Search Pattern to **/bin/*. This copies the folders myProject\bin\Debug and myProject\bin\Release folders and their contents to the package folder.
If I specify e.g. **/bin/**/*.nupkg or similar, nothing is copied, even though a respective *.nupkg file exists.
I found a solution to this problem:
Under Options set Copy to Staging Folder of the Visual Studio
Build-Configuration to true.
Use the search pattern **\bin*
Add a Command Line utility definition.
Let it execute C:\YourPathTo\nuget.exe with the arguments push C:\YourStagingPath**\bin***.nupkg -s [YourServer] [YourAPIKey]
Done.
Related
I have upgraded my company's TFS from 2013 to 2017. We still have our old XAML build definitions but are moving to the new JSON templates.
Most of the build definitions are working fine but some don't act like the former XAML definitions. I get all of the compiled assemblies in the $(Build.BinariesDirectory) folder but if I have a csproj that has Content items set to CopyAlways, they get copied to $(Build.SourcesDirectory), but they do not get copied into the $(Build.BinariesDirectory) for MSBuild. Project set up in Visual Studio
When building the old XAML build definitions they are copied to the bin directory fine: Build agent with the copied content
I have tried changing versions from 15 to the older 14 which still did not resolve this situation.
If you mean using the vNext build system, then you can add below msbuild arguments in the MSBuild Arguments area of the Visual Studio Build or MsBuild task to get the target files copied to the binaries directory.:
/p:OutputPath=$(Build.BinariesDirectory)
Note: The output is going to the \b\ folder, as the value of the variable $(Build.BinariesDirectory) is something like c:\agent\_work\1\b.
Build.BinariesDirectory :
The local path on the agent you can use as an output folder for
compiled binaries. For example: c:\agent\_work\1\b.
Source: Predefined variables
This is a winform application.
All dlls, exe and some other extension files are copied to the StartupProject\bin through the post build events(VS post-build).
On TFS Server, the project has 2 subfolders: bin and src.(bin contains required dlls, but other extensions are missing -.png, .dat, .xslx).
On the server, the post build copied files appear under the StartupProject\bin, but they are not copied to TFSFolder\bin.
How can I force copy all the StartupProj/bin to the TFSFolder\bin?
Team Build use a different directory layouts from Visual Studio builds. All Binaries go in a single folder for any project built, so references are automatically solved and it is easy to copy the DLL to the final Drop folder.
You should use $(OutDir) MSBuild variable to properly reference the binaries directory in VS and TFS builds. See Is there a single MSBuild and TFSBuild variable that will point to where the binaries are? for some details.
If you need to use different scripts for desktop (VS) and server (TFS) builds, use the $(BuildingInsideVisualStudio) variable as explained in TFS 2010 Build Automation and post-build event.
How can I set tfs build on agent to use one location for following files?
I have couple files that are run on after build of specific project.
files:
SomeFile.exe
RequiredDll.exe
I am using it for creating custom setups files, that is done from SomeFile.exe.
Now every time I have project that I want to run the actions, I need to copy files above into the project, which I know is wrong.
Is there any other way?
You can put these files in a common location within Source Control. Then in your build configuration you can map that common folder to a working folder for the build.
This is named slightly differently in the different versions of Visual Studio. In all versions it is found when editing a build configuration.
Visual Studio 2008 / 2010
Workspace
Visual Studio 2012
Source Settings
This allows you to map a source control folder to the Build Agents working build folder. You will then be able to access the same exe's in all your builds and they will only be in Source Control once.
A common practice is to have a Team Project dedicated to build artifacts. Then in your mappings you have something like this:
StatusSource Control FolderBuild Agent Folder
Active$/BuildProject/lib $(SourceDir)\BuildArtifacts
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.
Consider a .csproj containing the following directive:
< Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
There's a standalone TFS Build service installed on a machine, with a default Controller and one Agent. The TFS components were installed; Visual Studio was not installed.
When compiling an ASP.NET MVC 2 Web Application (targeting .NET 4), the TFS Build service encounters an error:
C:\somepath\foo.csproj (219): The imported project "C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
TF270015: 'MSBuild.exe' returned an unexpected exit code. Expected '0'; actual '1'.
It's true: there's no sub-directory "WebApplications" in the "C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0" directory.
It seems that this subset wasn't included in the install of the TFS Build service. TFS doesn't give any options on what pieces are installed for Build service.
What's the most appropriate way to install these artifacts, and any dependencies, on this TFS Build machine? Could this have been avoided?
Have you tried creating the path C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\ manually and copying the file Microsoft.WebApplication.targets there? If Microsoft.WebApplication.targets doesn't contain references to some specific build tasks that should do the trick.
At least that worked for Visual Studio 2005.
Check for unwanted references like 'stdole.dll' in your references and remove it.
connect to tfs again (to refresh)
try to build again.
Best solution is to always install VS2010 on your build machine.