Compile WebSite Project with NAnt - msbuild

I have a website project in Visual Studio 2008. I would like to build this website using MSBuild. I use the following command to build the solution:
msbuild.exe mysolution.sln /t:Rebuild /v:q
After I ran the command, it creates a new folder called precompiled, creates a copy of my project, removes all code files and places 1000 dll files in the bin folder.
Now when I do a "rebuild" from Visual studio, it doesn't do that.
Is there a way to rebuild the project without having it to create the precompiled folder?
Thanks

I think I found it. I should be using devenv.exe instead? How to build a .NET website using Nant

Related

Open CMake proejct in Visual Studio 2019 using command line

I use Visual Studio IDE to develop, VS C++ to compile, CMake to generate the project in VS and Ninja to build.
I have a script that clone a project from git server and automate several steps I need to perform before start working on it.
At the end of this script I would like to open the project in Visual Studio. Before I used to generate the VS solution instead and then use devenv with the sln file as a parameter to open it. But now that I use VS support for CMake if I use CMakeList.txt file as a parameter it only opens this file not the complete project.
Is there a way to do what I am trying to do??
Thanks in advance.
Assuming your project's root CMakeLists.txt is located in C:\project\CMakeLists.txt you can call
devenv "C:\project"
without the CMakeLists.txt.
Note that currently there seems to be a bug in Visual Studio 16.7 that when opening a directory, all the views (e.g. solution explorer) are hidden by default. (https://developercommunity.visualstudio.com/content/problem/1140297/visual-studio-is-forgetting-docked-viewwindow-layo.html)

How to use msbuild to generate a VS .sln file where everything is on x64 platform?

When I build my project in command line, everything works fine. But when I tried to generate a .sln file for the project by running msbuild /t:SlnGen /p:Platform=x64
at the command prompt, and then click build in VS (debug, x64), I got an error saying it can't copy a dependent binary folder because it is not found. Since my project is on CBT, I have x64, x86 and Any-CPU platform settings. My project used to be built on CoreXT. My suspicion is VS build doesn't handle the output path of the dependencies correctly.
Then how can I build the solution only on x64 through VS?
Any hint will be very helpful!

How to compile Visual Basic into .exe manually? [duplicate]

I am trying to compile my Visual Basic .NET project named Myproject.sln via command line commands. I need to build and compile that solution.
My Visual Basic .NET compiler is called vbc.exe. Any idea how I do that thing?
I am using Visual Studio 2005 , and I have already read Microsoft's tutorial, "Building from the Command Line (Visual Basic)".
The .NET framework (version 2 and above) comes with a command line build utility called MSBuild.
You can use this to build your Visual Studio project/solution files.
From the command line:
msbuild Myproject.sln
Just run MSBuild and specify the .sln file as a command line option:
msbuild myproject.sln /p:buildmode=release
You could look at using MSBuild. That's probably the best approach.
Your .sln file is a valid MSBUild project file, so if you open the Visual Studio command prompt from the start menu and browse to your project location,
c:\...\msbuild MyFile.sln
... for example, it should just work.

WCF compilation error on CI server: Microsoft.VisualStudio.ServiceModel.targets not found

I am getting this error on my CI server:
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" was not found
It seems my WCF service library project references that file, but the VisualStudio folder on Program Files\MSBuild\Microsoft doesn't contain a WCF folder.
I guess I need to install something on the server.
What do I need to install?
Well this ruined my morning, but let's not allow it to ruin anyone else's. I couldn't find this information anywhere else. You need to copy a few files from a development machine with VS Pro 2012.
As aphexddb mentions, you need to copy some targets from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF to the same location on your CI server.
This then references an assembly called Microsoft.VisualStudio.ServiceModel.Core. You can find this assembly in either the GAC or in the IDE directory at C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE.
Copy this to your CI server and execute gacutil.exe -i Microsoft.VisualStudio.ServiceModel.Core.dll
This was enough to fix it for me.
This isn't the first time I found targets missing from my VS express install in my CI server. I can't help but feel that there is some sort of package I can download from somewhere that fills all this in. Does anyone know of such a thing? If not, perhaps we should create one.
Can still happen on vs2019
error MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\WCF\Microsoft.VisualStudio.ServiceModel.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
WCF is not installed by default as part of 'ASP.NET and web development' workload. To fix this,
On visual studio installer > modify > individual components tab, search for wcf, check, modify - the .targets file gets now installed, msbuild builds ok.
MSBuild auto-detection: using msbuild version '16.3.2.50909' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin'
I ran into this with Visual Studio 2017, for me the resolution was to modify my installation of Visual Studio to include the Windows Communication Foundation components.
Extract this file into folder
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF
The file name is "Microsoft.VisualStudio.ServiceModel.targets"
Now you can solve the problem using the Nuget Package MSBuild.Microsoft.VisualStudio.Web.targets
so the build process does not require any change to the build server.
Install-Package MSBuild.Microsoft.VisualStudio.Web.targets
Details:
remove the element for "ServiceModels.targets" in the .csproj file
remove the target WebApplication from the build command (in yaml)
Ran into this same issue. Did the following to resolve:
Installed the Microsoft Web Platform Installer
Copied Directory "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\WCF" from dev laptop with Visual Studio 2012 to the build server
I've had the same error - my issue was that MS has modified the way MSBuild looks for the versions of VS in the build process template.
Make sure to use the right build process template.
If using TFS2013 and VS2013 use TfvcTemplate.12.xaml
I ran into this same error. In my case, the problem was that my Visual Studio 2008 project didn't get upgraded correctly, probably due to files being marked "read-only" by my source control. To fix it, I loaded the solution in Visual Studio 2015 with everything checked out.
The specific line in the .csproj file changed from
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" />
To
<Import Project="$(WcfServiceModelTargetPath)\Microsoft.VisualStudio.ServiceModel.targets" />
If you are using VS 2022 build tools, it is no longer in the individual components section. It is on the first tab "Workloads", included in ".NET desktop build tools", you will see it in the list on the right-hand side when you select it.

Command line compiling VB.NET project via Visual Studio?

I am trying to compile my Visual Basic .NET project named Myproject.sln via command line commands. I need to build and compile that solution.
My Visual Basic .NET compiler is called vbc.exe. Any idea how I do that thing?
I am using Visual Studio 2005 , and I have already read Microsoft's tutorial, "Building from the Command Line (Visual Basic)".
The .NET framework (version 2 and above) comes with a command line build utility called MSBuild.
You can use this to build your Visual Studio project/solution files.
From the command line:
msbuild Myproject.sln
Just run MSBuild and specify the .sln file as a command line option:
msbuild myproject.sln /p:buildmode=release
You could look at using MSBuild. That's probably the best approach.
Your .sln file is a valid MSBUild project file, so if you open the Visual Studio command prompt from the start menu and browse to your project location,
c:\...\msbuild MyFile.sln
... for example, it should just work.