Disable step in Visual Studio Extension build - visual-studio

While I am building own Visual Studio Extension in TeamCity (same applies to any CI server build that supports building VS solutions), my build stucks on the step DeployVsixExtensionFiles. As far as I understand, the target is defined in VS Extensibility files and is being imported into any .csproj by default. I also realize that this is an "aka test" step that tries to embed an extension into a virtual copy of VS via running a command:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe /RootSuffix Exp /ResetSettings General.vssettings /Embedding /Command File.Exit
I have two questions:
1. Should I disable this step for Release build of Extension?
2. If yes, how can this be done.

The VS SDK installs the extension as a part of a build so you can F5 and run it. If you're CI system doesn't care about that, update your CI configuration to pass /p:DeployExtension=false to MSBuild.

Related

How to build .vdproj in Azure DevOps pipeline

I am using windows self hosted agent with VS 2019 build tools installed. But in the build pipeline, I am unable to build ".vdproj" (.net framework 3.5) project. Please let me know whether installing of visual studio is the only option or any alternative approach available.
Thanks.
To build the .vdproj project, you will have to use devenv command to build the project.
Devenv.exe is the central Integrated Development Environment (IDE) for Visual Studio.
So you need to install the Visual Studio to get the Devenv.exe to build the project.
In Azure DevOps, you can add the Command Line Task and run the following command to build the .vdproj project.
For example:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe" MyProjectDir\MySolution.sln /Rebuild Release

MSBuild offline installer that comes with visual studio 2017 build tools not able to build project in Release mode

Step 1 - I have installed visual studio build tools by downloading
vs_BuildTools.exe from this site (you will require to login to microsoft account to browse this URL)
Step 2 - I created offline installer by following various articles particularly this one
And created zip file offlineBuildTools17.zip
Step 3 - Copied offlineBuildTools17.zip file to Build server which doesn't have internet connection.
Build server is Windows server 2012 R2.
Step 4 - Extracted Zip file on server and installed Build tools. Installation goes smoothly.
I could see installation files in
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft
Step 5 - I have simple DLL and Console application (.exe) project in my solution. These are simply 'hello world' application NOT USING DOT NET CORE. I am using .net frameowrk 4
Problem: I am unable to create release mode dlls and exe
Same thing is working on my laptop where I have installed visual studio 2017 community edition.
On laptop where visual studio 2017 installed
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild" <optional project.csproj> /p:Configuration=Release
This creates dlls and exe in bin\Release folder of project
But the same doesn't work on Build server.
Always creates dlls and exe in bin\debug folder.
My final goal is to create 'publish' folder
This is weird but it is solving my problem.
if i ran following command - msbuild is always generating Debug binaries. which was my original problem. it doesn't generate release mode binaries at all
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\"msbuild /p:Configuration=Release /t:publish /p:OutDir="./Publish"
But if i write following command , (note how msbuild is placed in double quote along with mbuild full path) it is working fine. it generates release mode binaries and also publish folders.
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild" /p:Configuration=Release /t:publish /p:OutDir="./Publish"
thanks

Get the output Dir of my TFS Build in a property usable by my project

I have this command in a post build event:
if $(ConfigurationName) == Release "$(SolutionDir)Tools\NuGet.exe" pack "$(ProjectDir)MyProject.Contracts.nuspec"
This works just fine when I compile in Visual Studio. But when my build runs this it fails. That is because someone somewhere thought it was a good idea to have builds on TFS not run the same as a build on a dev machine.
In this case it is the fact that all output files are grouped into a common "Binaries" folder.
So, my question is this:
Is there a property I can use (instead of ProjectDir) that will allow me to reference the output location of the build?
Meaning that it will point to the binaries folder when running a TFS build and point to my normal output when doing a normal Visual Studio based build.
I tried $(OutDir) but it equated to "bin\Release\"
UPDATE: I tried to use $(OutDir) but Visual Studio fails with the partial path it provides. Is there something that could be used with $(OutDir) to give a full path for both Visual Studio and TFS builds?
In case it matters:
TFS version is TFS 2010 (Latest releases installed)
Build Machine and Dev Machine are both running Windows 7 and VS 2010 Ulitmate
$(OutDir) should resolve to your bin\debug or bin\release etc for local builds, on the build server this will be resolved to the Binaries folder.
So yes, $(OutDir) should be the right one to use.

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

Resources