Build ASP.NET 4.5 without Visual Studio on Build Server - asp.net

Its been a while since I setup a Build Server so maybe I've forgotten something or maybe .NET 4.5 is different from whatever version I did this with last time, but here is my problem.
I'm trying to setup a build server to monitor a source control repository. Whenever something changes, I want the server to pull the changes and build the project. If there are no errors, I want to deploy the site to a web site running on the build server.
In the past when I did this, I thought that I was able to do this having only .NET installed, but when I try to build this project I get an error that "C:\Program Files\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" is missing, and if I go and look I can see that it is missing. In fact there are no Visual Studio 11 targets files.
After a lot of thought and head scratching, I went out and got the "Windows 8/.NET 4.5 SDK" thinking that the .NET 4.5 SDK might install the targets files that I needed, but it did not unless I installed it wrong somehow.
So, what do I need to put on the Build Server in order to get the project to build. I would prefer not to have to install the full Visual Studio 2012.

To run on on your CI server without Visual Studio, you only need to copy a few folders from a development machine to the same location on the CI server. There is no need to install the SDK.
VS 2015:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications
VS 2013:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications
VS 2012:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications
VS 2010:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications
.NET 4.6:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6
.NET 4.5.2:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2
.NET 4.5.1:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1
.NET 4.5:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5
.NET 4.0.1:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0.1
.NET 4.0:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
Or, as Matt suggested, you could copy them into a subdirectory of your project and alter the <MSBuildExtensionsPath32> location in your MSBuild (typically .csproj or .vbproj) file.
Once you have done this, your project will compile.
You should also set the VisualStudioVersion environment variable explicitly to the Visual Studio version (10.0 for VS2010, 11.0 for VS2012, 12.0 for VS2013, 14.0 for VS2015) you are using just to be sure it is set right in your configuration.

My problem was related to installing the Windows Software Development Kit (SDK) for Windows 8 on a Windows 2008 Box. If you read further on the page, you will get to a heading labeled ".NET Framework 4.5 SDK Tools on Windows Vista and Windows Server 2008." This tells you to:
Run the Windows SDK for Windows 8 installer on a supported operating system (for example, Windows 7, or Windows 8).
Choose the following option on the Specify Location screen: Download the Windows SDK for installation on a separate computer.
Press the Next button.
Answer the questions on the Join the Customer Experience Improvement Program (CEIP) screen.
On the next screen, choose the .NET Framework 4.5 Software Development Kit feature. Unselect all other features that can be unselected.
Choose the Download button.
Go to the download location (specified in step 2) and find the following .NET Framework 4.5 SDK tool installer files:
sdk_tools4.msi,
sdk_tools4.cab
You can copy these files to a Windows Vista or Windows 2008 Server computer within your organization. These files need to be copied to same directory on the Windows Vista or Windows 2008 Server computer.
Note: Do not redistribute these files outside your organization or as part of any other installer.
On the Windows Vista or Windows 2008 Server computer, review the license terms here .
Check whether .NET Framework 4.5 is already installed on the computer. Otherwise, download and install .NET Framework 4.5 from www.microsoft.com .
Open a command prompt with administrator privileges.
Go to the directory where .NET Framework 4.5 SDK Tools installer files were copied.
Install .NET Framework 4.5 SDK tools by using the command line:
Msiexec /i sdk_tools4.msi VSEXTUI=1

From msdn:
The Windows SDK no longer ships with a complete command-line build environment. You must install a compiler and build environment separately. If you require a complete development environment that includes compilers and a build environment, you can download Visual Studio 2012 Express, which includes the appropriate components of the Windows SDK.
In order to fix this, I had to copy the folder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5 from my development machine (which has Visual Studio 2012 by the way) onto the build agents. After this operation, Team City did not report any more errors and mscorlib.dll was not output to the bin folder.

Microsoft Build Tools 2013 will help in this case, as its download page describes:
If you don't have Visual Studio installed on your computer, you can
use Build Tools 2013 to build managed applications. The Visual Basic
and C# compilers are also included in this download. (In earlier
versions, these tools were included in the stand-alone .NET
Framework.)

My dept. likes taking a minimalistic approach to what's installed on our Win 7 build machines. However, we don't like just copying and pasting files/folders because of potential registry key issues. Instead of installing VS 2013, I installed the following much smaller and free components. Now the dev team can build VS 2013 web apps successfully.
.Net Framework v4.5.1, required to install the tools - http://www.microsoft.com/en-us/download/details.aspx?id=40779
MS Build Tools 2013, we needed the C# compiler - http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx
MS VS 2013 Isolated Shell, we needed the web app targets - http://www.microsoft.com/en-us/download/details.aspx?id=40764.

I solve this problem with Visual Studio Agents.
You can try install Visual Studio Agents 2012.
http://www.microsoft.com/en-us/download/details.aspx?id=38186

Related

How to include VC++ Redistributable Files Needed by CEFSharp

Building an application using the CEFSharp browser, works fine on my machine, but crashes on the server with the following error:
System.IO.FileLoadException: A procedure imported by 'CefSharp.Core.dll' could not be loaded.
I’ve seen this problem all over the internet, and the most common solution seems to be installing the VC++ Redistributable. However, I don’t have that access on our production server. In the development server, I tried installing the redistrituable (x86, x64, 2017, and 2013) and nothing made a difference. The computers are 64 bit, but the application is 32bit so I tried everything.
Can someone tell me what files specifically I need to add to the application directory to make CEFSharp work. Section 6 of this document: https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#6-how-do-i-include-the-visual-studio-c-2012-redistributables-on-the-target-app lists directories of files necessary, but I’m using Visual Studio 2017 and don’t have any of these directories on my machine.
Additional Info:
Development machine Windows 10, server 2016 Standard
Build set to x86, have not made any config changes for Any CPU mode
Windows Forms application
CefSharp version 71.0.0 from NuGet (& individually through Package Management Console Simple CefSharp application is missing files at runtime)
Not using any type of package or ClickOnce Deployment, manually
uploading all files from my computer to server
Update:
Although I'm still unable to get CEFSharp to work in my project, I accepted Peter Liapin's answer because it did answer the question I asked. Now I know what files in the VC++ Redistributable to copy to my application folder on the server, I just don't have the specific dlls he mentioned on my computer or on the server.
Additionally, I created a new test Windows forms project with CEFSharp and it worked on the server without the VC++ Redistributable dlls. However, I need the CEFSharp browser to work in a user control referenced by existing application.
The Visual C++ dlls you need to ship with your CefSharp based project:
If you use CefSharp v63.0.3 or below:
msvcp120.dll
msvcr120.dll
If you use CefSharp v65.0.0 or above:
#Example of files for VC++ 2017(141), there will be a few less files for VC++2015(140) and a few more for VC++ 2019(142), copy everything from the `Microsoft.VC14x.CRT` folder where `x` matches the VC++ Version
concrt140.dll
msvcp140.dll
msvcp140_1.dll
msvcp140_2.dll
vccorlib140.dll
vcruntime140.dll
Files can be found on your Dev PC in the:
C:\Windows\System32
C:\Program Files (x86)\Microsoft Visual Studio\[Version]\[Edition]\VC\Redist\MSVC\[Version]\[x64|x86]\Microsoft.VC14x.CRT folder.
See section at bottom if you are having problems finding the files on your machine, they are in slightly different folder structure for VS2015 compared to VS2017/2019
Note, you must have an appropriate version of Visual C++ or Visual Studio installed on your PC, otherwise you would not be able to find them:
Version 120 is installed with C++ Redistributable for Visual Studio
2013
Version 140 is installed with Visual C++ Redistributable for Visual
Studio
2015
Version 141 is installed with Microsoft Visual C++ Redistributable
for Visual Studio
2017
Universal CRT is required by Visual C++, on Windows 10 it is installed by default. Local deployment of the Universal CRT is supported see https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment?view=vs-2019#local-deployment
For Windows 7/8/8.1 you will either need the Universal CRT pre installed or deploy the files as per the link above.
To deploy redistributable Visual C++ files, you can use the Visual C++
Redistributable Packages (VCRedist_x86.exe, VCRedist_x64.exe, or
VCRedist_arm.exe) that are included in Visual Studio. In Visual Studio
2017, these files can be found in the Program Files[ (x86)]\Microsoft
Visual Studio\2017\edition\VC\Redist\MSVC\lib-version folder, where
edition is the Visual Studio edition installed, and lib-version is the
version of the libraries to redistribute. In Visual Studio 2015, these
files can be found under your Visual Studio installation directory in
Program Files [(x86)]\Microsoft Visual Studio
version\VC\redist\locale. Another option is to use redistributable
merge modules (.msm files), which in Visual Studio 2017 can be found
in the Program Files [(x86)]\Microsoft Visual
Studio\2017\edition\VC\Redist\MSVC\lib-version\MergeModules\ folder.
In Visual Studio 2015 these can be found in Program Files
[(x86)]\Common Files\Merge Modules. It's also possible to directly
install redistributable Visual C++ DLLs in the application local
folder, which is the folder that contains your executable application
file. For servicing reasons, we do not recommend that you use this
installation location.
As per https://learn.microsoft.com/en-us/cpp/windows/redistributing-visual-cpp-files?view=vs-2019 the locations for VS2015 are slightly different to VS2017/2019.
I had what appears to be the exact same issue, and I was able to get things working by copying msvcp140.dll and vcruntime140.dll into the bin folder of my application. I'm using CEFSharp 75.1.143 with cef.redist.x86 75.1.14.
Seems that Microsoft offers a unified installer for all C++ runtimes versions, from the 2015 to 2022.The installer is available on both 32 or 64bit, depending your architecture.
For details, check the Microsoft Visual C++ Redistributable latest supported downloads article.

Correct location of MSBuild.exe to build .net 4.5 application using command line

I have asp.net web api application targeting 4.5 framework.
I am trying to create a docker image for my application. In order to build the application, I can use MSBuild.exe available in C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe or C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe locations.
When I build using C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe location, I get error saying "
C:\MyApp-Api\MyApp-Api.csproj(985,3)
: error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft
\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not f
ound. Confirm that the path in the declaration is correct, and that th
e file exists on disk."
I am able to build my application using C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe location.
Questions:
What is the difference between the MsBuild.Exe available in these two folders?
Ideally I think using C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe location is the right approach as it comes with default location and I think MSBuild in program files comes due to installation of Visual Studio. and on my Build server I will not have visual studio installed.
In order to build the application on container, I need to specify SDK which will allow me to build the application. Which version of SDK, I need to build .net 4.5 application.
I was browsing web with a similar query today and stumbled upon this random link to a Veracode extension which lists nicely the difference.
Visual Studio 2017
The first two paths below that contain Professional differ based on the edition of Visual Studio you have installed. Replace Professional with Enterprise or Community, when appropriate.
Note: the Visual Studio Preview install also changes the path based on Enterprise, Professional, or Community.
Standard Visual Studio Paths
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\
Visual Studio Preview Paths
C:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\MSBuild\15.0\Bin
MSBuild Tools Paths
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\
Visual Studio 2015
C:\Program Files (x86)\MSBuild\14.0\Bin\
C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\
Visual Studio 2013
C:\Program Files (x86)\MSBuild\12.0\Bin\
C:\Program Files (x86)\MSBuild\12.0\Bin\amd64\
Visual Studio 2012
C:\Windows\Microsoft.NET\Framework\v4.0.30319\
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
It seems like you have both VS2012 and VS2015 installed.
I dont know much about ASP.NET and docker but will try to answer your questions:
I think the difference is explained above.
The problem you are experiencing there is explained better in here:
The imported project Microsoft.WebApplications.targets was not found Maybe give it a go?
Relying on https://dotnet.microsoft.com/download/visual-studio-sdks and
https://learn.microsoft.com/en-us/dotnet/framework/install/guide-for-developers it seems like there is no SDK for .net 4.5 as it is included in VS2012. But any higher version should build your project to 4.5 anyway.
Reading (3) I would use VS2015 msbuild if VS2012 gives you a headache.
If you dont mind me asking - Why not switching to ASP.NET Core ?

How to launch VStudio 2015 RC for ASP.NET vNext

I installed VSStudio 2015 from here: http://www.asp.net/vnext
Installation says success but I have no icon on desktop to run why?
VS2015RC installation did not put an icon on my desktop either, it is in the application menu though.
The exe should be located here.
C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\devenv.exe
You can create a shortcut and put it on the desktop yourself.
If you cannot find the folder maybe you need to reinstall or repair the installation.
The official download site is here. The community edition should have all you need to get started with ASP.NET 5 and all the vNext stuff.

One of my two TFS servers is missing VisualStudio tools in msbuild folder. Need help locating the package required to install them

I have two servers, ServerA and ServerB. Both servers have these installed:
Web Deploy 3.5" installed via Web Platform Installer
Microsoft .NET Framework 4.5.1 Multi-Targeting Pack
Microsoft .NET Framework 4.5.1 SDK
TFS 2013
ServerA is missing files that ServerB has. This is a huge problem because my MSBuild build arguments "/p:DeployOnBuild=True" do not work on ServerA unless I copy these specific files over.
ServerA
ServerB
When I manually copy these files over everything is fixed. But this isnt good practice and I need solid documentation on how to configure these servers. This post is what helped me find the issue: MSBuild DeployOnBuild=true not publishing
I always advise installing visual studio on the build servers. That should fix your problems.

Visual studio 2003 web projects

I have a requirement to work on a VS2003 web project.
I have VS2008,vs2010,vs2003 installed in my system
Other System details are
Windows Xp professional version 2 service pack 3. IIS 5.1
When i am trying to create a VS 2003 web project giving the localhost as path
i am getting the following error.
visual studio noted that specified web server is not running under asp .net 1.1 version.You will be unable to run asp .net web applications or services
I have used aspnet_regiis commands as well as a tool(ASPNETVersionSwitcher.exe ) to swith versions and in IIS also default web site ASP.NET version chosen as ASP.NET 1.14322.
I am still getting the error.
same error I get ,if I point a virtual directory in the existing 1.1 .NET web application and trying to open it.
Please advise, I have to work on this project as soon as possible.
Make sure all IIS Applications are using the same version of the framework. It is possible to have both 1.x and 2. I typically, uninstall using aspnet_regiis /ua which uninstalls all ASP.NET versions, then use aspnet_regiis to install ASP.NET as needed.
Make sure the "Virutual Directory" ASP.NET properties are correct for the version of Visual Studio you are using. Obviously, you cannnot use VS2k3 to connect to a ASP.NET 2.0 Virtual Directory.
Following is a dump of my installed ASP.NET versions.
C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_regiis -lv
1.1.4322.0 Valid (Root) C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\asp
net_isapi.dll
2.0.50727.0 Valid C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\as
pnet_isapi.dll
4.0.30319.0 Valid C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\as
pnet_isapi.dll
C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_regiis -lk
W3SVC/ 1.1.4322.2443
W3SVC/1/ROOT/ 2.0.50727.0
W3SVC/1/ROOT/Reports/ 2.0.50727.0
W3SVC/1/ROOT/ReportServer/ 2.0.50727.0
W3SVC/1/ROOT/ExceptionService/ 2.0.50727.0
W3SVC/1/ROOT/verification/ 2.0.50727.0
I've seen people create a virtual machine (pc) using Windows XP as the guest OS. They would then install Visual Studio 2003 on the virtual machine and do their development there.
From what I gather those people ran into a similar issue like yours.
Another solution that I have heard was that Visual Studio 2003 needs to be installed first, before Visual Studio 2005, 2008, or 2010 are installed. I've heard that works, but only from a clean OS install (you can't uninstall all the versions and start over.)

Categories

Resources