Deploy with New-AzureWebsiteJob and dotnet core? - powershell

I have an azure webjob that I can deploy fine through visual studio, right click publish etc. all that is fine. I am using Microsoft.Azure.Webjobs beta 3.0 against .NET Core 2.0. Of course when that project is built it creates a set of .dlls and no direct executable as is normal for .net core.
Now I want to create an integration test suite which will deploy my webjob to azure with Powershell, using New-AzureWebsiteJob. When I publish this way I get
New-AzureWebsiteJob : No runnable script file was found.
As far as I can gather my job file should have either: batch (.exe/.cmd/.bat), bash (.sh), javascript (.js as node.js), php (.php) or python (.py). If so what magic does VS do, and how should I go about scripting this?

Ok, found the solution. It is, however, inelegant. Create a file run.bat or similar containing
#ECHO OFF
dotnet YourLibraryName.dll
and include that in any zip file uploading with the cmdlet. More here

Related

How to remotely rebuild .NET solution with C#?

i have .NET project that is a IIS Service, this is on Windows Server2008 R2 Machine.
I have another project that is C# program, that using the IIS Web service,
my question is how can i rebuild solution/project of the Webservice from C# program?
Thank you
Can you confirm that you have source files which should be compiled and then compiled project should be placed to the directory which is used by IIS web application?
If yes, I would recomment to create a powershell script. This script would perform 2 main actions:
Compile the project. Use MSBUILD.exe utility for that.
Copy compiled folder. Use ROBOCOPY utility for that.
Then just call this script from your C# code.

Automate deployment of Service Fabric project without TFS or VSTS

I know you can publish a Service Fabric application written in C# using Visual Studio, and I have read this article on using TFS or VSTS to set up continuous integration DevOps builds of a Service Fabric application.
How can I just do this all manually using PowerShell? I know I can do the following using PowerShell from this article on deployment:
Use Visual Studio to package the project.
Transfer the package to a remote server.
Use the PowerShell script examples in the article to deploy the package while I am in the context of the remote server.
Instead, here are two bits I can't seem to figure out which would assist me in doing this from PowerShell:
Using PowerShell, how can I package my Service Fabric project the same way you can when you are in the context of Visual Studio?
Using PowerShell, how can I remotely deploy my Service Fabric project the same way you can when you are in the context of Visual Studio?
To generate the package through the command line, you can call the "Package" target on the sfproj file.
See my answer on create a deployment package for Service Fabric that includes all artifacts necessary to run the designed workflows at runtime
Then follow the instructions from https://azure.microsoft.com/en-us/documentation/articles/service-fabric-deploy-remove-applications/ as blackSphere suggested.
If you haven't seen this link, take a look at Deploy and Remove Packages using Powershell article.
Suppose you have a folder named MyApplicationType that contains the necessary application manifest, service manifests, and code/config/data packages. The Copy-ServiceFabricApplicationPackage command uploads the package to the cluster Image Store
That takes a directory and uploads it. Then you have to tell it to take that image and use it in the application.
The Register-ServiceFabricApplicationType command returns only after the system has successfully copied the application package. How long this takes depends on the contents of the application package. If needed, the -TimeoutSec parameter can be used to supply a longer timeout.
After you register it you can create the application:
You can instantiate an application by using any application type version that has been registered successfully through the New-ServiceFabricApplication command

Building a .NET Core app via command line, so that it works on a machine without .NET Core installed

My end goal is to create a cross-platform (non-web) console application, so I'm exploring .NET Core right now.
In my previous .NET projects, I did all the development inside Visual Studio, but I also created a batch/MSBuild file so I could build the whole project (including setups, NuGet packages, zip files with binaries etc.) with one single click. Here's an example from a previous project.
In the end, I want to do something similar with my .NET Core test project.
But right now I'm failing at the first step: I'm unable to build it outside Visual Studio, so that the result works on another Windows machine without .NET Core installed.
(in the first step, I'm ignoring the cross-platform part - I'll be happy to get it to work on Windows)
What I have
I managed to get it to work inside Visual Studio 2015 Community Edition as follows:
create new project in Visual Studio: "New Project" ⇒ "Web" ⇒ "Console Application (Package)"
create new publish profile inside Visual Studio ("Build" ⇒ "Publish" in the menu).
This will create a PowerShell script (and an XML file with settings)
Here's my test project on GitHub.
When I do "Build" ⇒ "Publish" in the menu again, Visual Studio apparently executes the previously created PowerShell script again.
The result is slightly over 90 MB, consists of 825 files in 598 folders, and looks like this:
When I copy it on another machine (Win 7 / .NET 4 installed / .NET Core not installed), it works.
What I tried to get the same result outside Visual Studio
1. dotnet publish
This answer and this answer sound like I can use dnu publish to achieve the same result via the command line.
I understand that parts of .NET Core are still moving targets right now, so apparently dnu is now dotnet instead.
So I tried to execute dotnet publish (and created a batch file) for it:
dotnet publish "%~dp0\src\CoreTestVisualStudio" -c Release -r win7-x64 -o "%~dp0\release\cli"
The result consists of an .exe file and a bunch of DLLs, only 25 files and 1.5 MB, all in one single folder:
Obviously the .NET Core runtime is missing here, and as expected, this app crashes when I try to execute it on a machine without .NET Core installed (the same one as mentioned above).
2. The PowerShell script from the publish profile
I tried to execute the PowerShell script (which was created when I created the publish profile) outside Visual Studio, but it failed because the script expects some parameters and I don't know what to pass:
param($publishProperties, $packOutput, $nugetUrl)
There's also this line in the script:
# to learn more about this file visit http://go.microsoft.com/fwlink/?LinkId=524327
...but the link just points to the landing page of the .NET Web Development and Tools Blog.
TL;DR
What am I doing wrong?
I know that the first release of .NET Core mainly focuses on ASP.NET, but as I understood it, ASP.NET Core apps are just console apps as well, so I thought a basic console app would work now.
On the other hand, most of the console app "getting started" docs are still missing, so maybe it's just too early and dotnet publish for console apps is not finished yet?
Edit after a few days: I'm suspecting that I'm doing nothing wrong and that it's an issue in the.NET Core command line tools, so I posted it to the command line tools' issue tracker.
Problem solved!
I posted it on the issue tracker of the .NET Core command line tools, and it turned out that it was a bug in dotnet publish - it didn't bundle the C++ runtime, which is needed to execute the compiled app on a machine without .NET Core installed.
The temporary solution was to install the C++ runtime.
The "real" solution was made in a pull request three days ago, which is included in the latest installer now.
With this version, dotnet publish does bundle the C++ runtime, so the result will work on a machine without .NET Core.
For dnu:
There's an option for dnu publish called --runtime that specifies the runtime to include when publishing. You would use the full runtime name with the command, e.g.:
dnu publish --runtime dnx-clr-win-x86.1.0.0-rc1
For dotnet:
You don't need to specify the runtime or framework versions -- by default, dotnet publish will use the framework from project.json and the current runtime flavor. However, the documentation states that:
dotnet-publish command also requires certain dependencies in the project.json to work. Namely the Microsoft.NETCore.Runtime package must be referenced as a dependency in order for the command to copy the runtime files as well as the application's files to the published location.

Compiling just one class in netbeans in a web app

I was wondering if there is a way to compile just the file I have changed in a web application project rather than building the whole project again. It takes a lot of time to build the project all over again rather than just compiling that one file. I am able to use the "run test" feature to check if the class has been written properly.
I would check out the JRebel plugin for NetBeans. JRebel is a hot deployer that works with web servers.
http://zeroturnaround.com/software/jrebel/installing-jrebel-for-netbeans/
http://zeroturnaround.com/software/jrebel/

Running ASP.NET web application from command line

I have ASP.NET web application and would like to run it. The machine doesn't have Visual Studio installed on it. On my machine which has Visual Studio I was able to run the application using the steps mentioned in this link
http://www.codeproject.com/Articles/166319/Run-ASP-NET-Web-Application-from-Command-Prompt
However, the production box doesn't have WebDev.WebServer20.EXE. Obviously the exe file could be downloaded and then I could run the program, but on production box I can't do that.
Is there any other way to run ASP.NET program from command line? It is a simple program, I am not using any third-party dll files and there are no command line arguments.
Is there any other way to run ASP.NET program from command line? It is
a simple program, I am not using any third-party dll files and there
are no command line arguments. I have has IIS. Could you tell me what
to do next. Actually I am not a .NET developer so not familiar with
all this. Any help would be great.
You are missing basic concepts.
You do not need to run ASP.Net Web Application like executable program. Production Sever doesn't need Visual Studio; it just requires IIS and targeted .Net Framework.
Since you have Visual Studio on your local machine, you can publish straight to production server. Here is an example. - OR - Publish files to local folder and copy file to production folder.
Then create a site in IIS, and map Physical Path.
Take a look at hostable web core. For example http://blogs.iis.net/carlosag/archive/2008/04/14/host-your-own-web-server-in-your-application-using-iis-7-0-hostable-web-core.aspx

Resources