Running Ef core migration on the server - asp.net

Does any know how to run EF core command on a server with VS 2017.
I have SDK 2.0.3 installed on the server.
I ran this command from source code folder:
dotnet exec --depsfile auth.deps.json --runtimeconfig auth.runtimeconfig.json ef.dll migrations list --assembly auth.dll
and got this error:
No project was found. Change the current working directory or use the
--project option.

Try this:
Copy the content this files
ef.dll
ef.runtimeconfig.json
From:
C:\Program
Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.tools.dotnet\2.0.0\tools\netcoreapp2.0
to your source files, open command prompt in admin mode, point to you source file folder and run your command again

Related

dotnet publish command is not creating zip file for C# library

In visual studio solution I have single .net core 2.0 library project. And to the publish the library i am using dotnet publish -c release command
however its not zipping the publish folder. I have read the issue 6598 and use the suggested approach using dotnet build command as below
dotnet build ApiRouting.sln /nologo /p:PublishProfile=Release /p:PackageLocation="C:\temp\Routing\package" /p:OutDir="C:\temp\Routing\out" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /maxcpucount:1 /p:platform="Any CPU" /p:configuration="Release" /p:DesktopBuildPackageLocation="C:\temp\Routing\package\package.zip"
`
but that did not work either.
My project is aws lambda project which is C# library project not asp.net web project so i tried removing /p:WebPublishMethod=Package option but that did not work either.
Questions
1>What parameters i need to pass to publish command so that it would create zip file of publish folder.
2>In linked issue 6598 why its suggested to use build command instead of publish when build command only builds the project?
(on side note i can use aws tools for visual studio and use Publish to AWS Lambda and it creates zip file and deploys it to AWS directly from visual studio. However, we are using Jenkins for CI so i want use dotnet cli to create zip file so jenkins can execute that command and create zip file.)
i found it. These 2 links helped me
https://docs.aws.amazon.com/lambda/latest/dg/lambda-dotnet-how-to-create-deployment-package.html
https://docs.aws.amazon.com/lambda/latest/dg/lambda-dotnet-coreclr-deployment-package.html
first installed Amazon.Lambda.Tools
dotnet tool install -g Amazon.Lambda.Tools
and then to package and deploy
dotnet lambda deploy-function apirouting –-function-role myrole --profile lambdadep --profile-location C:\test\testawsprofile

Execute npm install command after one-click publish in Visual Studio

I have enabled one-click publish with IIS Web Deploy for my MVC5 application. I would like to be able to execute the 'npm install' command in the publish directory ideally after the files have been published.
I understand that via command-line, I can use the 'postsync' argument to execute a command, but is it possible to modify my .pubxml file to include a command that will execute the 'npm install' command? (therefore I can publish directly from Visual Studio without having to use command-line).

Publishing a dotnet application that's already running

I'm attempting to create a script to simplify the process of publishing a .NET Core website. I'm running into an issue when I run dotnet publish against an already running server. The server is IIS with the dotnet bundle installed, so IIS uses its app pool to start dotnet.
Here's my batch file. I'm happy to use another script type:
cd src/app
dotnet build --no-incremental
dotnet publish --framework netcoreapp1.0 --configuration Release --output ../../dist
When I run the script I get this error:
"The process cannot access the file 'C:\inetpub\wwwroot\app\dist\app.dll' because it is being used by another process."
This makes sense, it appears I need to stop, deploy, and restart dotnet. Can I do this from the script? Or is my approach to this problem wrong?
The best way is to drop an app_offline.htm file to your application folder. This will make IIS stop your application and serve the contents of the app_offline.htm file to the user while you are copying the new version. Once you complete copying the new version of your application remove the app_offline.htm file and IIS will start your application.
You can find more details on running ASP.NET Core applications with IIS in my post.
Based on Pawel's answer, I have a deploy folder containing my app_offline.html file and multiple deploy scripts to IIS. Here's a sample script I use to deploy:
copy .\app_offline.htm C:\hosting\my-project\app_offline.htm
dotnet publish ../MyProject.csproj -r win-x64 -f netcoreapp2.1 --self-contained -c Release -o C:\hosting\my-project
del C:\hosting\my-project\app_offline.htm
I think this is a valid solution, but doesn't help when I want to script the build process.
Stop-Website "xxx"
Stop-WebAppPool "xxx"
Start-Sleep -Seconds 5
dotnet publish --output d:\publocation
Stop-WebAppPool "xxx"
Start-Website "xxx"
if you've created a published profile in Visual Studio and you're using IIS, then you can use that profile instead of writing directly to the destination directory:
dotnet publish /p:PublishProfile=Properties\PublishProfiles\IISProfile.pubxml

GIT based asp.net web app fails to deploy to Azure with typescript compile error

I have this asp.net (4.6.2) web application which compiles and runs fine on my local machine.
The project is in a Git repo in VSTS.
I want this site deployed to Azure web sites. So I make a Webapp and set the deployment option to my VSTS Git repo.
This will automatically trigger a deployment... which fails.. with this error:
All packages listed in packages.config are already installed.
D:\home\site\repository\FormBuilder\Scripts\typings\knockout\knockout.d.ts(335,13): error TS1110: Build: Type expected. [D:\home\site\repository\FormBuilder\FormBuilder.csproj]
D:\home\site\repository\FormBuilder\Scripts\typings\knockout\knockout.d.ts(338,11): error TS1109: Build: Expression expected. [D:\home\site\repository\FormBuilder\FormBuilder.csproj]
D:\home\site\repository\FormBuilder\Scripts\typings\knockout\knockout.d.ts(339,1): error TS1128: Build: Declaration or statement expected. [D:\home\site\repository\FormBuilder\FormBuilder.csproj]
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\FormBuilder\FormBuilder.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="D:\local\Temp\8d3e9219d2f6f3b";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="D:\home\site\repository.\"
An error has occurred during web site deployment.
It looks to me like it's compiling my .d.ts files. Don't know why..VS2015 does not do that.
I tried to exclude this file in a tsconfig but that does not work.
How can I make this build succeed?
So the problem is that the Azure build machine is not equipped with typescript 2.0 (yet) and knockout.d.ts uses a 2.0 syntax for something. See the comments below the question.
GitHub issue here
You need to compile type script files before deploying to azure. In deploy.cmd file on azure you can add this code to Compile TypeScript right after the npm packages are installed.
echo Transpiling TypeScript in %DEPLOYMENT_TARGET%...call :ExecuteCmd node %DEPLOYMENT_TARGET%\node_modules\typescript\bin\tsc -p "%DEPLOYMENT_TARGET%"
You can find the deploy.cmd file on KUDU in site->deployments->tools section.

Unable to publish ASP.NET web site using command line

I have a VS 2012 solution(ASP.NET) that contains three projects. I'm trying to deploy/publish the site via MsBuild command line without installing Visual Studio on our build machine.
I am using:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild Myproject.csproj /p:DeployOnBuild=true /p:PublishProfile= pubfile.pubxml /p:Password=user1 /p:AllowUntrustedCertificate=true
MY Command line output show only "build successfully" of the solution but nothing about the publish profile.
The same solution and batch file run successfully on my local machine.
Please suggest If any option for publishing without install VS on build Machine
I had to add the following to my command line
/p:VisualStudioVersion=11.0
or you might have to install Web Deploy on your build machine.
The other thing I had to do was publish from VS and save a publish profile and then used that on the command line. I see you have pubfile.xml, but all I had to do was reference the profile name, not the file name. QA being my profile name from the project. Try removing the .xml on the end of yours.
/p:PublishProfile=QA
Add C:\Windows\Microsoft.NET\Framework\v4.0.30319\ to your %PATH% system environment variable and invoke your command:
msbuild Myproject.csproj /p:DeployOnBuild=true /p:PublishProfile= pubfile.pubxml /p:Password=user1 /p:AllowUntrustedCertificate=true

Resources