I'm trying to deploy my ASP.NET 5 Beta 7 web application to Azure platform using Continuous Deployment on Visual Studio Online.
I've already follow these guides:
https://msdn.microsoft.com/en-us/Library/vs/alm/Build/azure/deploy-aspnet5 -> to deploy asp.net 5 web apps
http://www.brandonmartinez.com/2015/09/16/deploying-asp-net-5-beta-7-through-vso/ -> changes to previous guide to deploy asp.net 5 Beta 7 web apps
When I commit and push a changes, the build task triggers correctly but it fails when executing prepublish script of project.json:
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
The error (warning) is:
npm WARN optional dep failed, continuing fsevents#1.0.0
I was able to deploy by enabling Continue on error option in the build definition and only for PublishLocal.ps1 step (that fails).
Visual Studio Online completes (partially) the build and deploy my site to Azure and everything seems to works without problems, but, what is that error? There is a way to fix it?
Here is my PublishLocal.ps1 step (from http://www.brandonmartinez.com/2015/09/16/deploying-asp-net-5-beta-7-through-vso/):
#Requires -Version 3.0
param($vsoProjectName, $projectName, $buildConfiguration, $buildSourcesDirectory)
$VerbosePreference = "continue"
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
$globalJson = Get-Content -Path $PSScriptRoot\global.json -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore
if($globalJson)
{
$dnxVersion = $globalJson.sdk.version
}
else
{
Write-Warning "Unable to locate global.json to determine using 'latest'"
$dnxVersion = "latest"
}
& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent
$dnxRuntimePath = "$($env:USERPROFILE)\.dnx\runtimes\dnx-clr-win-x86.$dnxVersion"
& dnu build "$PSScriptRoot\src\$projectName" --configuration "$buildConfiguration"
& dnu publish "$PSScriptRoot\src\$projectName" --configuration "$buildConfiguration" --out "$buildSourcesDirectory\$vsoProjectName\artifacts\bin\$buildConfiguration\Publish" --runtime "$dnxRuntimePath"
Without seeing your entire build log, it's a little difficult to diagnose. However, my assumption is that NPM is writing WARN messages to stderr. As such, the VSTS build server will see that as an error instead of a warning.
I would recommend either adding --quiet to your NPM scripts, or update your dependency to not throw the WARN. You could also changed the PowerShell script VerbosePreference to SilentlyContinue to see if that stops printing the message as well.
Related
I believe I followed every single step mentioned in the documentation but can't seem to get images load with 'next start' script.
Next.config.js
images: {
domains: [
'dev.mydomain.com',
'qa.mydomain.com',
'stg.mydomain.com',
'mydomain.com',
],
},
I have images in public/assets/images directory. These are .png files
In my React component that is used on one of the pages, I have
import Image from 'next/image';
import homeIntroImg from '../../../public/assets/images/homeIntro.png';
.....
<Image
src={homeIntroImg}
alt="Home Introduction"
placeholder="blur"
/>
As mentioned in docs, I have installed 'sharp' and added environment variable. /usr/src/app is the working directory path in docker.
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "NEXT_SHARP_PATH=/usr/src/app/node_modules/sharp next start ",
Dockerfile
FROM base-image-node-16.0:latest AS runner
WORKDIR /usr/src/app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1
USER 2020
COPY --chown=2020:2020 . /usr/src/app
EXPOSE 3000
CMD [ "npm", "run", "start" ]
On local when i try to build docker container,
I get
Warning: For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended. Run 'yarn add sharp', and Next.js will use it automatically for Image Optimization.
but images load fine.
When the same docker image is deployed to cluster, the initial load time is almost 10-15 sec. This wasn't happening like this when I run the app using 'node server.js'. I wanted to use 'next start' as recommended to get optimization benefits but now I question if it is worth to use 'next start' if it takes 10-15 sec for load.
images do not load and fail with 503 service unavailable error.
I see the 'Sharp' warning and right after that 'npm' crashes
Warning: For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended. Run 'yarn add sharp', and Next.js will use it automatically for Image Optimization.
Read more: https://nextjs.org/docs/messages/sharp-missing-in-production
Killed
Am I missing anything? Any help is greatly appreciated.
I'm trying to use nix for building dotnet (sdk 5) projects.
The configuration is something like
stdenv.mkDerivation {
# builder = "${bash}/bin/bash";
# args = [ ./builder.sh ];
name = "mypackage";
src = ./.;
HOME = "/tmp/test-home";
DOTNET_CLI_TELEMETRY_OPTOUT = 1;
nativeBuildInputs = [ nodejs ];
buildInputs = [ dotnet openssl cacert ];
configurePhase = ''
export HOME=$PWD/home
runHook preConfigure
dotnet nuget list source
dotnet nuget locals all --list
dotnet restore
runHook postConfigure
'';
buildPhase = ''
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1
${dotnet}/bin/dotnet publish ProjectDirectory --self-contained -r linux-x64 -c Release
'';
installPhase = ''
mkdir -p $out/
'';
};
The HOME attribute in argument for stdenv.mkDerivation is for nix-shell only. Since nix-shell will inherit normal $HOME, I need to set $HOME to another empty directory to mimic behavior of build phase.
When using nix-shell and run dotnet restore manually, it works fine.
When using nix-build, build failed with following error when running dotnet restore
Registered Sources:
nuget.org [Enabled]
https://api.nuget.org/v3/index.json
http-cache: /build/PROJECTNAME/home/.local/share/NuGet/v3-cache
global-packages: /build/PROJECTNAME/home/.nuget/packages/
temp: /build/NuGetScratch
plugins-cache: /build/PROJECTNAME/home/.local/share/NuGet/plugins-cache
Determining projects to restore...
/nix/store/fvfyn01fjmawvyn7vlhhrgkzyy6321wl-dotnet-sdk-5.0.202/sdk/5.0.202/NuGet.targets(131,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [/build/PROJECTNAME/PET-CT-machine-service.sln]
/nix/store/fvfyn01fjmawvyn7vlhhrgkzyy6321wl-dotnet-sdk-5.0.202/sdk/5.0.202/NuGet.targets(131,5): error : Name or service not known (api.nuget.org:443) [/build/PROJECTNAME/PET-CT-machine-service.sln]
/nix/store/fvfyn01fjmawvyn7vlhhrgkzyy6321wl-dotnet-sdk-5.0.202/sdk/5.0.202/NuGet.targets(131,5): error : Name or service not known [/build/tomopioneer/PET-CT-machine-service.sln]
What's the difference between nix-build and nix-shell --pure when HOME is manually set?
By reading code from github NixOS/nixpkgs repository, it seems several dotnet packages were using nuget manually and using dotnet restore with local source. Is that necessary?
I've make more tests about api.nuget.org.
running curl https://api.nuget.org/v3/index.json -v, I got:
works fine when directly run under terminal of nixos
works fine in nix-shell --pure
error in nix-build, curl: (6) Could not resolve host: api.nuget.org
nix-shell has network access which is not allowed in the sandbox that nix-build uses without a fixed output derivation.
By reading code from github NixOS/nixpkgs repository, it seems several dotnet packages were using nuget manually and using dotnet restore with local source. Is that necessary?
With sandbox enabled yes.
Used the VS2017 angular template and created an app. Then tried to publish it. I also upgraded to Angular 5.
Any idea with this error about ngfactory is about ???
ERROR in ./ClientApp/boot.server.ts
Module not found : error : Can't resolve './../$$_gendir/ClientApp/app/app.server.module.ngfacto
ry' in 'C:\Users\Matt_Herb\downloads\ibewsurveytemp\ibewsurveytemp\ClientApp' [C:\Users\Matt_Her
b\downloads\ibewsurveytemp\ibewsurveytemp\IbewSurveyTemp.csproj]
# ./ClientApp/boot.server.ts 8:0-94
EXEC : ERROR in error : Please update #angular/cli. Angular 5+ requires at least Angular CLI 1.5
+ [C:\Users\Matt_Herb\downloads\ibewsurveytemp\ibewsurveytemp\IbewSurveyTemp.csproj]
at throwNotSupportedError (C:\Users\Matt_Herb\downloads\ibewsurveytemp\ibewsurveytemp\
packages\compiler-cli\src\ngtools_api.ts:132:9)
at Function.NgTools_InternalApi_NG_2.codeGen (C:\Users\Matt_Herb\downloads\ibewsurveyt
emp\ibewsurveytemp\packages\compiler-cli\src\ngtools_api.ts:80:11)
at _donePromise.Promise.resolve.then (C:\Users\Matt_Herb\downloads\ibewsurveytemp\ibew
surveytemp\node_modules\#ngtools\webpack\src\plugin.js:430:58)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
at Function.Module.runMain (module.js:684:11)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:613:3
C:\Users\Matt_Herb\downloads\ibewsurveytemp\ibewsurveytemp\IbewSurveyTemp.csproj(48,5): error MS
B3073: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2.
ok ... it looks like a problem with your dependencies and so on ..try this:
1 - update your angular cli with : npm install -g #angular/cli
2 - delete your node_modules in your project (maybe with rimraf)
3 - delete your package-lock.json file (if you've one)
4 - try to run in a different folder ng new testProject --skip-install=true (so it generate WITHOUT install packages a new angular project ..)
5 - go in that project and copy the #angular and other dependencies in package.json file and paste in your project .. save the updated package.json
file of your project
6 - run a npm install --f in your project
7 - try to run a ng serve .. and check if the project load
Hope it helps you
Angular 5 needs to use a different compiler plugin to Angular 4,
Try search/replace 'AotPlugin' with 'AngularCompilerPlugin' in webpack.config.js
see: https://www.npmjs.com/package/#ngtools/webpack
The next problem I ran into was that test files fail to compile when publishing,
The 'exclude' properties on webpack rules and on AngularCompilerPlugin constructor do not seem to work, so I've resorted to excluding these in tsconfig.json:
"exclude": [ "bin", "node_modules", "**/*.spec.ts" ],
Background
Within an Electron app, sqlite3 doesn't work right after npm install --save. I got it working after doing some web research, by:
(1) downgrading my node version (via n) to match Electron's node version; and
(2) rebuilding sqlite with the right module name/targets with this package.json script:
"rebuild-sqlite3": "cd node_modules/sqlite3 && npm run prepublish && node-gyp configure --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.2-darwin-x64 && node-gyp rebuild --target=1.2.6 --arch=x64 --target_platform=darwin --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.2-darwin-x64"
After that, Sqlite3 works in development (i.e. when I run electron . in the project dir).
Problem
I package the app with electron-packager: "./node_modules/.bin/webpack -p && ./node_modules/electron-packager/cli.js ./ --out ./bin --platform=darwin --arch=x64 --version=1.2.6 --overwrite --ignore=\"ignore|bin|node_modules\""
When I open the app by double-clicking the created (appName).app, the console complains: `Uncaught Error: Cannot find module
Question
How can I get sqlite3 to be found in the final packaged product? Even "hacks" or workarounds are welcome, as I tried various fixes to no avail.
I leave this answer for someone who has the same problem and is wasting their time to figure out.
step1
npm install sqlite3
electron .
I expected to work fine. but I had an error 'cannot find node module sqlite3'
step2
npm install electron-rebuild --save-dev
electron-rebuild -f -w sqlite3
electron .
it worked.
but if you used 'electron-packager' to package and make executable file, It didn't work. the same error occured.
"electron-packager . electron-tutorial-app --overwrite --asar --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=new --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Electron Test\"",
step3
I spent pretty much time to figure out. At the end, I figured out. the solution was using electron-packager API and integrating afterCopy with electron-rebuild.
# build.js
const packager = require('electron-packager');
const rebuild = require('electron-rebuild');
packager({
dir: '../dir',
overwrite: true,
asar: true,
platform: 'win32',
arch: 'ia32',
icon: 'assets/icons/win/icon.ico',
prune: true,
out: 'hello',
executableName: 'hello',
afterCopy: [(buildPath, electronVersion, platform, arch, callback) => {
rebuild.rebuild({ buildPath, electronVersion, arch })
.then(() => callback())
.catch((error) => callback(error));
}],
})
node build.js
reference
electron-rebuild manual 'How can I integrate this into Electron packager?'
electron-packager API doc
Doesn't the --ignore=\"ignore|bin|node_modules\" you pass to electron-packager ignore everything in the node_modules dir, the very place where the sqlite3 module is installed?
We have a Solution created with VS2015.1 that has 3 projects, all of them DNX RC1.
| sln
|+---MVC6 Api
| project.json
| +---ClassLibrary
| Class.cs
| project.json
| \---Webjob
Program.cs
project.json
Both the API and Webjob reference the ClassLibrary in their project.json files.
"frameworks": {
"dnx451": {
"dependencies": {
"ClassLibrary": "1.0.0-*"
}
}
}
We created 2 WebApps, both tied with Continuos Integration to the Solution repo and each with a Project Application Setting that points to the API folder (in one) and the Webjob folder (in the other).
The API project gets deployed without problem, when it tries to resolve the local project dependency it works:
Using Project dependency ClassLibrary 1.0.0 for DNX,Version=v4.5.1
Copying source code from Project dependency ClassLibrary
Source D:\home\site\repository\ClassLibrary\project.json
Target D:\local\Temp\8d32044390806ef\approot\src\ClassLibrary
The Webjob on the other hand, fails, it tries to resolve it as a nuget remote package and fails:
[01/21/2016 19:47:45 > b597c3: INFO] GET https://api.nuget.org/v3-flatcontainer/ClassLibrary/index.json
[01/21/2016 19:47:46 > b597c3: INFO] NotFound https://api.nuget.org/v3-flatcontainer/ClassLibrary/index.json 507ms
[01/21/2016 19:47:46 > b597c3: ERR ] Unable to locate Dependency ClassLibrary >= 1.0.0-*
This last part I had to check it through Kudu, since it's done on the first run of the WebJob apparently and not during the deploy phase (like with the API).
Running the WebJob locally works without issues.
I tried the solution in publish dnx based WebJob with local dependencies but didn't work.
After talking with the Product Team, the 3 project scenario won't work right now by default.
The solution described on publish dnx based WebJob with local dependencies works for a 2 project scenario, but if you need to deploy a WebJob AND a Web App that depend on the same Class Library project and the 3 are on the same repo, you can't make the Webjob deploy from Continuous Integration.
The solution is to set Continuous Integration for your Web App (it will work by default) and manually deploy your WebJob as a zipped file.
Go into your WebJob folder and run dnu publish.
Go into bin/output/approot/src/YourWebJobFolder.
Edit the autogenerated CMD file.
Use this script by customizing line 4:
#ECHO OFF
:: 1. Prepare environment
SET DNX_CONSOLE_APP_PATH=Autocosmos.Trunk.Webjob
SET DNVM_CMD_PATH_FILE="%USERPROFILE%\.dnx\temp-set-envvars.cmd"
:: 2. Install DNX
CALL PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%DNVM_CMD_PATH_FILE%';& '%SCM_DNVM_PS_PATH%' " install latest
IF ERRORLEVEL 1 GOTO ERROR
:: 3. Put DNX on the path
IF EXIST %DNVM_CMD_PATH_FILE% (
CALL %DNVM_CMD_PATH_FILE%
DEL %DNVM_CMD_PATH_FILE%
)
call :ExecuteCmd dnx --project "%~dp0src\%DNX_CONSOLE_APP_PATH%" --configuration Release %DNX_CONSOLE_APP_PATH% run
goto end
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%
:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul
:exitSetErrorLevel
exit /b 1
:exitFromFunction
()
:end
endlocal
echo Finished successfully.
Then ZIP bin/output/approot and Upload it to Azure.