Gulp task to web deploy from Visual Studio - msbuild

I have not found a concrete example on how to do the publishing via a Gulp Task. Anyone has an idea?
This is how i'm trying at the moment.
gulp.task("Deploy-To-Azure", function() {
var targets = ["Build"];
console.log("Publishing to Azure");
return gulp.src(["./src/Feature/Accounts/code"])
.pipe(foreach(function (stream, file) {
return stream
.pipe(debug({ title: "Building project:" }))
.pipe(msbuild({
targets: targets,
configuration: "Azure",
logCommand: false,
verbosity: "verbose",
stdout: true,
errorOnFail: true,
maxcpucount: 0,
toolsVersion: 14.0,
properties: {
DeployOnBuild: "true",
DeployDefaultTarget: "Web Deploy",
WebPublishMethod: "FileSystem",
DeleteExistingFiles: "false",
_FindDependencies: "false",
Configuration: "Release"
}
}))
.pipe(debug({title: "Finished building project"}));
}));
});
But it looks like the project is built but not deployed. I think my properties are not complete. Any ideas are appreciated. Thank you

I attempted to use those same MSBuild properties from the commandline and received the following error:
>c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild /p:DeployOnBuild=true /p:WebPub
lishMethod=FileSystem /p:DeleteExistingFiles=false /p:DeployDefaultTarget="Web Deploy"
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.P
ublishing.targets(4449,11): error MSB4057: The target "Web Deploy" does not exi
st in the project. [c:\users\me\documents\visual studio 2015\projects\w
ebapplication12\WebApplication12.csproj]
Unless you've created a custom MSBuild Target named "Web Deploy". This won't work.
When I remove the /p:DeployDefaultTarget="Web Deploy" property a WebDeploy package is created in the /obj/[configuration]/Package folder.

Try DeployDefaultTarget: "WebPublish"

Related

Nunit.framework dll from the package doesnt get copied to bin folder

I'm currently running .net framework 4.6 and added the NUnit, NUnit3TestAdapter nuget package to the test project that i am working on and I see that the test's are not being discovered.
Upon some investigtion, I see that nunit.framework.dll is not being copied to the bin folder. Did some more research and I see the following in the assets.json file, and Nunit's build/NUnit.props file which is supposed to have the MSBuild settings is empty and does not have any.
"NUnit/3.13.3": {
"type": "package",
"compile": {
"lib/net45/nunit.framework.dll": {}
},
"runtime": {
"lib/net45/nunit.framework.dll": {}
},
"build": {
"build/NUnit.props": {}
}
},
However Nbuild/Unit3TestAdapter.props file which is installed from the official Nunit has the MSBuild settings. Is there a reason why build/NUnit.props does not have the build setting where as build/Unit3TestAdapter.props has these?
Also, Is there a work-around to get these copied to local or should I add the reference's manually than getting these from the package?

Publish and Run an ASP.NET Core 1.0 Application in Production

On an ASPNETCORE 1.0 application I have the following on Startup:
public Startup(IHostingEnvironment hostingEnvironment) {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder
.SetBasePath(hostingEnvironment.ContentRootPath)
.AddJsonFile("settings.json", false, true)
.AddJsonFile($"settings.{hostingEnvironment.EnvironmentName}.json", false, true);
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
I have 2 settings files on my project:
settings.json
settings.production.json
I published the project using the command line:
set ASPNETCORE_ENVIRONMENT=production
dotnet publish --configuration Release
The published files include settings.json but not settings.production.json. And settings.json does include the properties which are only in settings.production.json. Shouldn't they be merged on publish?
In top of this how to make sure that the application runs on production mode when I copy the files to my server?
Do I need to do anything on Web.config?
You need to update your project.json to add your settings.production.json file to the include section of publishOptions:
{
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"settings.json",
"settings.production.json",
"web.config"
]
}
}

Nancy support for .NETCoreApp

Trying to add the Nancy package to a new project. In project.json (dependencies segment) red squigly under "Nancy": "1.4.3". Mouseover displays an error relating to support for .NETCoreApp
The master branch of Nancy on github already runs on .net core.We are moving from Rake to Cake for the build script , hoping to wrap that up this week so .netcore support can be pushed to Nuget.So yes wait just a bit.
This example was original written on Stack Overflow Documentation:
Setup Nancyfx with Dotnet core v1.1, Kestrel, and Visual Studio Code on *nix systems
Prerequiste steps:
Get dotnet core for your platform:
Dotnet Core
Follow instructions and make sure dotnet core is working
Get Visual Studio Code for your platform:
VS Code
Launch Visual Studio Code (VS code) and install the C# extension then reload
Create self hosted NancyFx project:
Setup a project with a correct project directory structure.
Open Bash Terminal and type:
mkdir nancydotnetcore
cd nancydotnetcore
mkdir src
mkdir test
touch global.json
Open global.json and enter the following code:
{
"projects":["src", "test"]
}
In Bash terminal:
cd src
mkdir NancyProject1
dotnet new
Open folder NancyProject1 in VS code
You will get a warning: "Required assets to build and debug are missing from 'nancyproject1'."
Click "Yes"
Also you will see: There are unresolved dependencies from 'project.json'. Please execute the restore command to continue.
Click "Close" we will get to this soon.
Add the dependencies, open "project.json" and overwrite it with the following:
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.AspNetCore.Hosting": "1.1.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.Owin": "1.1.0",
"Nancy": "2.0.0-barneyrubble",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
}
}
}
}
}
VS code will ask to restore click "Restore"
Create folder "Modules" in VSCode project
In the Modules folder add a file named "IndexModule.cs" then copy and save the following:
namespace NancyProject1
{
using Nancy;
public class IndexModule : NancyModule
{
public IndexModule()
{
Get("/", _ => "Hello dotnet core world!");
}
}
}
In the root directory of the project create a file called "Startup.cs" and copy and paste the following:
namespace NancyProject1
{
using Microsoft.AspNetCore.Builder;
using Nancy.Owin;
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseOwin(x => x.UseNancy());
}
}
}
Open file "Program.cs" and overwrite the content with the following and save:
namespace NancyProject1
{
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseKestrel()
.UseStartup()
.Build();
host.Run();
}
}
}
Done! Now lets run this and see the output.
Click the debug symbol in VS Code, and Click the run button. It should compile and start the project.
Open the browser # http://localhost:5000
Pat yourself on the back and enjoy!
still pre release version but works with .net core as the time of this writing, view engines are very limited on core.
Install-Package Nancy -Version 2.0.0-barneyrubble -Pre

"Error: cannot file config find .jshintrc " in cli after cloning the git repo and running grunt

When i try to run grunt , i am getting error as "cannot file the config file .jshintrc". I tried to install the config dependencies but nothing is working out.Can anyone tell me how to resolve this particular error. Do i need to define any particular rule in my grunt.js file as I believe this should be generated automatically in the root folder after running grunt.
The piece of lines for jshint task in grunt.js is-
grunt.initConfig({
lesslint:{
src: ['src/']
},
jshint: { // configure the task
all: ['src/app/**/*.js'],
options: {
reporter: require('jshint-html-reporter'),
reporterOutput: 'out/jshint-report.html',
//force report
force: false,
// JS Validation rules are configured in .jshintrc file.
jshintrc: '.jshintrc'
}
});
Any help is much appreciated.

Durandal.js optimizer not working (empty main-built.js)

I'm trying to get Durandal.js optimizer working on my test project, but it seems to generate nothing to main-built.js. I use the following command from node.js command prompt, in durandal/amd folder:
optimizer.exe --verbose true
Result is
Using default base configuration.
Configuring for deploy with almond (custom).
{
"name": "durandal/amd/almond-custom",
"inlineText": true,
"stubModules": [
"durandal/amd/text"
],
"paths": {
"text": "durandal/amd/text"
},
"baseUrl": "C:\\Users\\Tommi Gustafsson\\Documents\\Visual Studio 2012\\Projects\\DurandalTests\\DurandalTest1\\TestApp",
"mainConfigFile": "C:\\Users\\Tommi Gustafsson\\Documents\\Visual Studio 2012\\Projects\\DurandalTests\\DurandalTest1\\TestApp\\main.js",
"include": [
"main-built",
"main",
"bindings/tinymce-binding",
"durandal/app",
"durandal/composition",
"durandal/events",
"durandal/http",
"text!durandal/messageBox.html",
"durandal/messageBox",
"durandal/modalDialog",
"durandal/system",
"durandal/viewEngine",
"durandal/viewLocator",
"durandal/viewModel",
"durandal/viewModelBinder",
"durandal/widget",
"durandal/plugins/router",
"durandal/transitions/entrance",
"raphael-amd/eve.0.3.4",
"raphael-amd/raphael.2.1.0.amd",
"raphael-amd/raphael.2.1.0.core",
"raphael-amd/raphael.2.1.0.svg",
"raphael-amd/raphael.2.1.0.vml",
"viewmodels/flickr",
"viewmodels/modal1",
"viewmodels/myPage",
"viewmodels/shell",
"viewmodels/welcome",
"text!views/detail.html",
"text!views/flickr.html",
"text!views/modal1.html",
"text!views/myPage.html",
"text!views/shell.html",
"text!views/welcome.html"
],
"exclude": [],
"keepBuildDir": true,
"optimize": "uglify2",
"out": "C:\\Users\\Tommi Gustafsson\\Documents\\Visual Studio 2012\\Projects\\DurandalTests\\DurandalTest1\\TestApp\\main-built.js",
"pragmas": {
"build": true
},
"wrap": true,
"insertRequire": [
"main"
]
}
Deleting old output file.
Tracing dependencies for: durandal/amd/almond-custom
Then, when I check main-built.js, it is empty. Can anyone help me what is the problem? I have several AMD modules in the test project, including Raphael.js AMD modules.
My requirejs configuration looks like this:
requirejs.config({
paths: {
'text': 'durandal/amd/text',
'eve': './raphael-amd/eve.0.3.4',
'raphael.core': './raphael-amd/raphael.2.1.0.core',
'raphael.svg': './raphael-amd/raphael.2.1.0.svg',
'raphael.vml': './raphael-amd/raphael.2.1.0.vml',
'raphael': './raphael-amd/raphael.2.1.0.amd',
'tinymce': "../Scripts/tinymce/jquery.tinymce.min"
}
});
In the same amd folder, where optimizer is stored, try running node r.js -o app.build.js. I've seen r.js sometimes choke about some dependencies, which resolves without problem when loading via require.js. For whatever reason the error messages won't show up when using optimizer --verbose. Typically the error message provides enough information to see where this occurs and if you've to update require.contig.paths or a specific define dependency.