How do we use command lines or Script (msbuild) to build Cordova Project created with Visual Studio Tools for Apache Cordova? - visual-studio-cordova

I use Visual Studio to create Cordova projects. I need to build Cordova projects using msbuild and buildbot via script for my project but I can find only information about how VS combine with Cordova CLI to build multi device hybrid application.

Our Visual Studio team has published some tutorials for building Cordova projects using Team Foundation Server 2013 and MSBuild. There may be some pointers in here you could adapt for your needs, if you still need help.
https://github.com/Microsoft/cordova-docs/blob/1d1c0872ac3b2f22301138915efcfa1dd87caea8/tutorial-team-build/TFS2013.md
Are there specific issues you encountered when trying to run an msbuild command from the command line to build a .jsproj project?
Jordan, Microsoft Visual Studio team

Related

Cannot compile template C++/CLI (.NET Core 3.1) project via dotnet build command

Install latest stable Visual Studio 2019 16.4.2 (check .NET Core Development and Desktop development with C++ workloads, also make sure that C++/CLI support component in checked).
Create new project with CLR Class Library (.NET Core)
template (or CLR Empty Project (.NET Core) if you like).
Compilation via dotnet build command will fail (dotnet build CLRNetCoreTest.sln
/p:Configuration=Debug /p:Platform=x86):
Compilation via msbuild command is successfull ("%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" CLRNetCoreTest.sln /p:Configuration=Debug /p:Platform=x86).
And that is very strange - I supposed dotnet to be a wrapper built on the top of msbuild..
Sample project is attached (run Build.bat for compilation).
To add more details:
And that is very strange - I supposed dotnet to be a wrapper built on
the top of msbuild.
Agree with Martin, dotnet build for now doesn't support building C++ project, cause dotnet cli doesn't know where to find the necessary C++ xx.targets and xx.props.
Your project is a C++/CLR project(xx.vcxproj) whose target framework is .net core, it has big difference with actual .net core projects(xx.csproj or xx.vbproj), the xx.vcxproj imports many C++ specific files which is not included in .net core sdk.
For example: Go C:\Program Files\dotnet\sdk\xxx you can find many msbuild targets and props files there, but you can't find Microsoft.Cpp.Default.props file. This file comes from C++ workload instead of .net core SDK.
So though dotnet build uses msbuild to build project, it actually doesn't use the same msbuild.exe from VS folder(C:\Program Files (x86)\Microsoft Visual Studio\xxx\xxx\MSBuild\1xxx\Bin\MSBuild.exe). And only the msbuild.exe from VS IDE or MSBuild build tools package can be used to build this project.
In addition:
If your final goal is to build the project in remote server, maybe you're looking for Build Tools for Visual Studio 2019` package.(Free if you've gotten corresponding lisense, more details see this) It doesn't require VS IDE to be installed. (Download link here)
C++ projects can only be built with the msbuild.exe shipped with Visual Studio as it relies on Visual Studio's C++ tooling.
The cross-platform dotnet command with its cross-platform MSBuild distribution does not have these tools and as such unable to compile C++ projects. The dotnet command does not use the visual studio version of MSBuild.

How to package and deploy asp.net web application

I am currently working on automating the build and deploy of an asp.net web application which is developed using vb.net in visual studio. Currently, developers are building the solution and projects using visual studio IDE. In the solution, they have deployment/setup projects (vdproj) for each environment (e.g.: app.setup.dev, app.setup.uat, app.setup.prof) which creates msi for the deployment and the web.config is embedded on it.
We are using github for scm, jenkinsfor build/CI and udeploy for deployment.
I am able to build the solution using msbuild cli thru jenkins. However, vdproj cannot be built using msbuild. Alternatively, I installed Visual Studio and MS VS Installer Projects Extensions in my build server, then build the vdproj using devenv. I am not sure if that is a correct way, maybe it is just a workaround.
What is the appropriate way to package the deployment artifacts (contents files, dlls, web.config) and deploy them? And How? If there’s another way to do it rather than creating MSI, it would be great as I don’t have to get a license for the Visual Studio in my build server.
I am currently working on automating the build and deploy of an
asp.net web application which is developed using vb.net in visual
studio.
Maybe you can try publish asp.net web-app by msbuild command-line.
1.As far as I know, we can build and deploy by Visual Studio, see this document.
2.And without VS, you can build and deploy(publish?) by msbuild command-line, there are many resources about this topic.
See:
How to deploy an ASP.NET MVC application on build using MSBuild in Visual Studio 2015?.
How to build and deploy a web deployment package using MSBuild
Using MSBuild.exe to “Publish” a ASP.NET MVC 4 project with the cmd line
In this way, you can get similar function by specifying the parameters and don't need to have VS installed in the server.
What is the appropriate way to package the deployment artifacts
(contents files, dlls, web.config) and deploy them?
Do you have to package them into .msi or .zip and then publish it. If not, simple msbuild command like: msbuild xxx.sln /p:WebPublishMethod=xxx /p:PublishProfile=xxx is enough.
Not certainly sure if it's what you want, hope it helps.

TFS 2017 Deploy ASP .NET Core

We are on TFS 2017 initial release (on premise install). I am looking to see how I can build ASP .NET Core 2.0 apps using TFS 2017 Build / Release. Right now our standard builds uses Visual Studio builds and we have visual studio 2015 installed on our build server.
When I am attempting to build ASP .NET core 2 MVC app, using Visual Studio build, the build is failing with an error message :
Trunk\xxxxxx.csproj (1, 1)
Trunk\xxxxxx.csproj(1,1): Error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.
Can I ask what is the recommended approach to building / deploying .NET core 2.0 projects using TFS 2017?
Install VS 2017 on the build server? We already have VS 2015 installed on the build server. Can VS 2015 and VS2017 live side by side on the build server and will the VS build step pick up 2017?
Visual Studio Builld
Or should we be installing .NET core 2.0 SDK on the build server and then use command line utility as a part of the build step.
Or should we switiching to MSBUILD instead of VS studio build and installing just the MSBuild for VS 2017 on the builld server.
1.You could install VS2017 on the build server. VS2017 and VS2015 could live side by side on either a build server or a develop machine. You just need to select which version you will use in visual studio version picklist. However VS2017 option is not support on the build-in Visual Studio Build task on TFS2017. It's not related to VS2017 installed on the build server or not.
2.You need to install .NET CORE 2.0 SDK on the build server, otherwise will get a similar error as below:
error : The version of Microsoft.NET.Sdk used by this project is
insufficient to support references to libraries targeting .NET
Standard 1.5 or higher. Please install version 2.0 or higher of the
.NET Core SDK.
Highly recommend you to keep the build server environment as same as local develop machine, this will narrow down the build issue on TFS.
3.No you don't have to. Just follow the process in this tutorial-- Build your ASP.NET Core app
Suggest you update your TFS 2017 initial release to the latest version TFS2017 update2. This will include VS2017 in the picklist of vs version. And since .NetCore 2.0 released in May 2017 which is later then the initial TFS2017(November 2016), not sure if it's supported or have any other issues. However, one thing is certain: you could build .NET Core 2.0 apps in TFS2017update2 successfully. Moreover, there are many new features released with update2 version, there is no reason to stay on the initial TFS2017.

Using TestTools.UnitTesting .Net Core

I am building a new project with .NET Core using Visual Studio 2015. The project builds and compiles as expected. I tried to to add a reference to Microsoft.VisualStudio.TestTools.UnitTesting the way I would do this with a ASP.NET project would be References->Add Reference etc. Seems I am unable to add it this way with Visual Studio 2015. I found an article here that suggests building a project from the CLI. dotnet new mstest. However that results in this message on my machine:
Specify --help for a list of available options and commands.
Unrecognized command or argument 'mstest'
I tried the same command on Ubuntu machine and it creates the project without a problem.
I am on a Windows machine.
Any insight on this?
I see the same on my computer when I try to use dotnet new mstest as well as dotnet new xunit for Visual Studio 2015 on Windows 10. I tried dotnet new mstest in Developer Command Prompt for VS 2017 and it worked fine, though.
I don't know the reason for sure as to why it's not available for 2015, it might be a limitation at this time of the dot net core tooling available for VS 2015 on Windows.
However, the reason I'm posting this as an answer is because I was eventually able to get mstest setup with the following workaround:
I had to manually include the following into the appsettings.json file of a new .Net CORE project that I created through the Visual Studio 2015 IDE:
"testRunner": "mstest",
"dependencies": {
"dotnet-test-mstest": "1.1.1-preview",
"MsTest.TestFramework": "1.0.4-preview",
...
}
After that, mstest works for me in that project in VS 2015 and tests are discovered by the Test Explorer.

Pre Build Tasks with Visual Studio Tools for Apache Cordova

I am using bower.json to install dependencies for an Apache Cordova app created from Visual Studio and was wondering if it is possible to run a pre build task somehow in VS 2015 using the new task runner explorer (or another way) to copy just the minified files from bower_components to www\scripts or if my only option is what is listed here?
If it is possible using gulp, please let me know how starting form the blank Cordova app VS template.
The Visual Studio guidance for using NuGet with Cordova projects actually has something that may help here. That document includes a note about how to setup a before_prepare hook to copy NuGet files into the www folder when building. In Cordova before_prepare is one hook into the build process that is similar to a Pre Build task.

Resources