Jenkins - Visual Studio Command line arguments - visual-studio

Planning to Build & Deploy SSIS Projects(ISPAC) or Database Solutions (DAPAC) from Jenkins using Visual Studio Command line arguments.
Question: I know i can execute Windows batch commands but i would like to if i can execute Visual Studio Commands as well.
FYI: Planning to install Visual Studio on the Agent.

I think you will be able to do it using msbuild. If your SSIS solution can be compiled by Visual Studio, the msbuild command can do it as well (See also msbuild integration).
To utilize msbuild to create an ispac/dapac file take a look at this article. It's not Jenkins specific but that should not matter.

Related

command line solution build using devenv rebuilding more projects than visual studio solution build

I am trying to mimic visual studio solution build from command prompt using batch script but there is significant difference between manual solution build(ctrl+shift+b) inside visual studio and command line solution build using devenv in terms of project rebuild counts. More projects are getting rebuilt from command line in comparison to visual studio solution build.
I am using this for command line build in batch file:
call"C:\ProgramFiles(x86)\MicrosoftVisualStudio\2019\Professional\VC\Auxiliary\Build\vcvars32.bat"
devenv solution_name.sln /build "Debug"
command line solution build output looks like this: devenv solution build using cmd prompt
visual studio solution build output looks like this: manual vs solution build output
I have tried changing the configurations too but it didn't help, I am curious why this might be happening and is there a way to get same result from command line build as of manual vs solution build?

How to build Visual Studio Installer Project in Azure Devops Pipeline Hosted Agent

I have a Visual Studio setup project. Normally I use the Microsoft Visual Studio Installer Projects extension, and run an MSBuild Exec task with command line using devenv. This works on my dev box and my existing build machine. However I'm looking to migrate to a hosted pipeline agent using the VS2017 image.
I was hoping the installer extension might already be installed, so I tried my build and got an error:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.com" "D:\a\2\s\Source\Build..\WindowsFormsApp1\WindowsFormsApp1.sln" /Build "Debug" /Project "Setup1" /ProjectConfig "Debug" /Log
The operation could not be completed. The parameter is incorrect.
I tried adding the VSIX to my repo, and then issuing a command line install of the VSIX as such:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VSIXInstaller.exe" /a /quiet /log:MyTestApp.log D:\a\2\s\Source\Build\InstallerProjects.vsix
However that seems to block for about 10 minutes, and then fails with an error (I suspect the UI is blocking even though I used the /quiet arg to suppress the UI):
... exited with code -2146233088.
Is there any way to build a Visual Studio installer project using a MS-hosted pipeline agent?
How to build Visual Studio Installer Project in Azure Devops Pipeline Hosted Agent
AFAIK, I am afraid we could not build Visual Studio Installer Project in Azure Devops Pipeline Hosted Agent at this moment.
I encountered a similar issue two weeks ago, after a period of investigation, I started to try the same idea as you, using command line to install the Microsoft Visual Studio Installer Projects extension.
However, I got the timeout issue. I could not install that extension on the hosted agent. To test the reason for this, I use the same command lien to installed that extension on another local machine. Indeed, there is a UI window to confirm if you want to install this extension, even after I give the /admin parameter:
Check the options here.
Then I try to open the command line with Administrator and execute the same command line, it can successfully install that extension. So, I want to execute the command line in the Azure DevOps pipeline. But no success. Because we could not execute command line script as admin using Command Line Script task.
It seems we have to set our private agent.
Hope this helps.

MSBuild Console - How to Add Additional Include Directory?

I have setup a new server machine. I setup windows sdk, .net framework sdk, and checkout my visual studio from svn. I would like to build my application using msbuild but it keeps asking me where the "windowsx.h" file is. I do not want to setup any visual studio ide. How can I make msbuild see windows sdk include folder using console?
With a normal install of Visual Studio you get a shortcut to a Visual Studio prompt. This sets all environment variables so you can use the compiler (and other tools) from the command line. First you can try to run msbuild from such a prompt. If that works add the necessary folders to the msbuild settings.

MsTest fails when running unit tests as part of CI using TFS 2008

My configuration:
VS2010 solution
TFS 2008
Build server - TFS 2008
Build server also has VS2008 Team Suite and VS2010 ultimate installed
TFS 2008 builds my VS2010 solution properly. But when it comes time to run the unit tests I get the following MsTest error.
Using "TestToolsTask" task from
assembly "D:\Program Files\Microsoft
Visual Studio
9.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll".
Task "TestToolsTask" Command:
d:\Program Files\Microsoft Visual
Studio 10.0\Common7\IDE\MSTest.exe
/nologo
/searchpathroot:"D:\Builds\App\Source\86\Binaries"
/resultsfileroot:"D:\Builds\App\Source\86\TestResults"
/testcontainer:"D:\Builds\App\Source\86\Binaries\\Tests.dll"
/publish:"http://tfsServer:8080/"
/publishbuild:"vstfs:///Build/Build/26029"
/teamproject:"Proposal" The
"TestToolsTask" task is using
"MSTest.exe" from "d:\Program
Files\Microsoft Visual Studio
10.0\Common7\IDE\MSTest.exe". No platform specified for publish
operation. For switch syntax, type
"MSTest /help"
MSBUILD : warning MSB6006: "MSTest.exe" exited with code 1.
[D:\Builds\App\Source\86\BuildType\TFSBuild.proj]
The previous error was converted to a
warning because the task was called
with ContinueOnError=true. Build
continuing because "ContinueOnError"
on the task "TestToolsTask" is set to
"true". Done executing task
"TestToolsTask" -- FAILED.
I am not sure what is causing MsTest to fail.
Things tried:
- Provided write access to the build folder to the service account that builds the source on the build machine
You can execute a VS2010 build from within TFS2008's MSBuild, but it looks as if it's using Visual Studio 9.0 TestToolsTask (2008) to try to run a Visual Studio 10.0 (2010) test project (MSTest.exe). I'd try tweaking MSBuild to run the TestToolsTask from the "Microsoft Visual Studio 10.0" folder rather than "9.0", so that the entire process is using the same version of the tools. You can override the tools paths in your tfsbuild.proj file's Properties to ensure the correct version of Visual Studio is used to build with - something similar may apply to the test tools.
Alternatively, it's running the VS2010 test tools correctly, but still trying to use a command line that is specific to 2008 - check the settings and see if you can tweak the command line (you may need to override the MS targets files that is running the build if it's a 2008 version). For example in TFS 2010, a lot of command lines changed from using a simple "server:MyServer" to something like "collection:http://MyServer:8080/tfs/MyCollection". You may therefore have to alter the command line to gain full compatibility with the 2010 version of the tool that is now running, even if it still ultimately points at a 2008 server.
My third suggestion (which isn't necessarily very helpful) is to just upgrade to TFS2010 - it's typically a painless install, vastly better than 2008, and will eliminate any difficulties caused by using a hybrid 2008/2010 setup. (If it helps, I was reluctant to upgrade to 2010 because the 2005->2008 upgrade was 8 days of sheer hell. But in comparison the core of the upgrade to 2010 only took a few hours and "just worked" - the install/upgrade process is much improved)
Jason had the correct idea that lead me down to the correct solution.
In my case, I had to update the "Microsoft.TeamFoundation.Build.targets" to point to "Microsoft.TeamFoundation.Build.ProcessComponents.dll" (VS2010 dll) instead of "Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll" (VS2008 dll)
I also had to make sure that the PlatformToBuild was specified in the TfsBuild.proj file.
Once these 2 steps were done, UnitTests were being run as part of the CI build using TFS2008 and a VS2010 solution.
I have blogged about the solution in detail here: http://blog.aggregatedintelligence.com/2011/03/vs2010-tfs-2008-and-unit-tests.html

PowerShell Script To build Visual Studio Project

Is there any powershell script exist to build visual studio project without open visual studio?
You don't even need power shell or visual studio. Just use the msbuild program installed with .Net. Usage example is like this:
msbuild DBMigration.csproj /p:Configuration=Debug
msbuild is located at C:\Windows\Microsoft.NET\Framework\v3.5 (or select your version)
There is also a powershell build system, https://github.com/JamesKovacs/psake

Resources