Visual Studio Team Services build with external dll - c#

I have to build several dozen repositories using Visual Studio Team Services. I have two problems.
How to build repository wich has other external .dll in reference. Can I download it somehow in definition step from sftp or other place?
These repositories have to be build with diferent sets of .dll references. For now we build them changing properties of the project in VS, now we would like to have this functionality in our build definition in VSTS. For example: we would like to build repository with 12.1, 12.2, 12.3 sets of external .dll reference and produce three Artifacts after one pull request.
I have no experience with VSTS, can anybody give me some advice?

In VSTS build, you can only build the sources from one repository for a build. So there are two options you can use:
1. Add external dll into the current repo you need to build.
You can add the dll in your current repo, and then refer the dll from your current repo. Then commit and push the changes and build by VSTS.
2. Add the repo which has the dll you are referring as a submodule for your current git repo.
By adding submodule, you can use the external dll directly. One thing to note, you just need to select checkout submodules in your VSTS build defintion.

Related

Is there a way to have a C# solution use project references when local and nuget packages during TFS builds?

We've got two sets of projects, one is framework projects and the other is the actual app. The app references the framework projects directly via the visual studio project reference feature. The framework build process publishes a nuget package already. Is there any way to make it so when I trigger a build on TFS of the actual app it uses that nuget package instead of the project reference? Ideally I'd like to have it still be a project reference when local, but if that's not possible that's alright.
I discovered you can use conditionals in the csproj files to determine which item group to use, and by making a custom build configuration I can specify which item group to use on TFS.

Refer assemblies(artifacts) from artifactory in .NET

I'm trying to make my .Net project work with Artifactory. So far I've uploaded the reference assemblies(.dll) files to artifactory using Jenkins. Now to build my solution, I want to refer those uploaded reference assemblies(artifacts) from artifactory, rather than referring them from the local path.
I tried using the MSBuild artifactory plugin, but it has a partial support for Jenkins.
Is there a way to do this?
You can not reference dll directly from Artifactory. To use them as dependencies in your project you have two options :
first one is to download them locally before your build (you can
setup a prebuild step for that)
second one is to create a nuget
package containing these dlls, to upload this nuget package to
Artifactory (this is where the MsBuild Artifactory plugin can help
you) and use it as a nuget dependency within your project where the
nuget feed used by Visual Studio will be configured to reach
Artifactory nuget repository.

TFS 2015 "vNext" Build for web project in solution

I am trying to achieve setting up a vNext build definition on TFS 2015 (the project is actually a .NET 4.6.1 web project, but I want to use the new TFS build setup). I am struggling with finding documentation on only deploying a specific web project in my solution (2 web projects, 3 class libraries and subsequent tests).
In the XAML build approach, I would specify the .sln and the .csproj file relevant to the build in the Process > 2. Build > Projects input. The "Visual Studio Build" step does not allow for multiple project inputs in the same way, and this seems to be where I am getting stuck. If I only specify the .csproj, Nuget packages do not get restored and the build fails.
Is there any known documentation for deploying a C# web project (.csproj) ONLY via these vNext builds?
MSBuild arguments previously used in XAML Build:
/p:AllowUntrustedCertificate=True /p:AuthType=NTLM /p:Configuration=Development /p:DeployOnBuild=True /p:PublishProfile="DEV" /toolsversion:14.0 /p:VisualStudioVersion=14.0 /p:GenerateBuildInfoConfigFile=false
The solution I am searching for would accomplish the following:
Builds at the very least the Web.csproj with project dependencies
Restores Nuget packages
Transforms web configs
Deploys Web project to two separate servers (non-Azure!) via, ideally, web deploy
Thanks in advanced for any help. Hopefully this is possible!
Note: I am not on Azure and Azure is not an option. I know there are tons of documented use case scenarios for Azure users, which is great... but, yeah.
You can add a "NuGet Installer" task at the top of your build definition to restore the nuget packages for your solution and specify the .csproj in Visual Studio Build Step.
If you want to build the entire solution, you can add following arguments in "MSBuild Arguments":
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
This will create the deploy packages for your projects separately in "$(build.artifactstagingdirectory)\" folder like following:
Then you can choose the package for the project you want to deploy. And with the deploy package, you can add two "Command Line" tasks in your build definition and call "Project.deploy.cmd" under "$(build.artifactstagingdirectory)\" folder to deploy the project to your servers. Reference about deploy from command: Executing the Command File. Web.config will be transformed by default if you have configured it correctly.
By the way, I recommend you to deploy your projects by using the release management system instead of deploying them in build.

Visual Studio reference separate git project

Example
C# Project A is stored in internal Git Repository A
C# Project B is stored in internal Git Repository B but references Project A
Question
What is a simple way for Project B to reference a Project A?
Options considered
Install, configure, and deploy internal NuGet server
Check Project A's dll into git and use npm since it has the ability to add a dependency directly to a git url (including version)
Use git submodule
Use git subtree
Copy Project A's dll manually into Project B
I'd suggest Nuget, but you don't need a server. Nuget can work from a simple local folder. Setting it up takes one minute.
Set up a git repo for the packages and clone it on your machines. In VS, Tools->Options->Nuget, configure a new package repository pointing to your local folder.

Integrating Source Code into a Visual Studio Project

I'm using a NuGet package called Hangfire in my VS project. However I'd like to be able to step thru each Hangfire API which is not possible as these files are under the "References" folder, so I've downloaded a copy of the Hangfire source code from Github. However, how do I integrate this code into an existing Visual Studios Project? Or maybe even simpler, instead of installing a NuGet Package, how do I reference the methods in the HangFire source code in my VS Project?
In order to reference these files, you'll need to...
Add the Hangfire project (or projects!) into your Solution. This can be done by right-click -> add existing Project on the solution.
Make sure that you're referencing the Hangfire in the Solution. This can be ensured by removing all references, and then readding them, making sure to draw from the Solution section in the Add Reference dialog.
Make sure the Hangfire projects are set to build in the dependant configurations. This can be done by selecting the Configuration Manager either in Solution settings or via the configuration or platform drop-down. Make sure the Hangfire projects are checked for any configuration/platform combinationin which your projects are selected
Assuming you have a repo for you project (and you always should), you may also be able to embed Hangfire as a subrepo in your repo, so updating and keeping versions synced is easier.

Categories

Resources