Msbuild packaging Issue - msdeploy

Currently I am working on a mvc3 project and I use msbuild command line tool to do the packaging.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>msbuild MVC-Client.csproj /t:package /P:Configuration=staging
In my machine this command executes successfully and it creates a deploy-able package.And in deploy bat file it has following web deployment configs.
MSDeployPath="C:\Program Files (x86)\IIS\**Microsoft Web Deploy V2**\"
And but when I am trying to run same msbuild command in my build server machine(jenkings server) it creates a different bat file with following web deployment configs.
set MSDeployPath="C:\Program Files (x86)\IIS\Microsoft Web Deploy\"
In both machines I use same version of msbuild. And also i have both msdeply1 and msdeploy2 installed in those machines. What could be the reason for this ? I am using Microsoft (R) Build Engine Version 4.0.30319.1 version of msbuild.
Thanks

It's seems that install web deploy v1 after Web deploy v2, try to reinstall Web Deploy v2 on your build server.

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

VSTS msdeploy.exe error: ERROR_USER_NOT_AUTHORIZED_FOR_CONTENTPATH

I'm trying to create a release definition inside VSTS to deploy my ASP.NET Core 2.0 app on my production server.
I'm using the MSDeployAllTheThings extension: https://marketplace.visualstudio.com/items?itemName=rschiefer.MSDeployAllTheThings
I'm able to deploy inside Visual Studio using the same configuration...
VSTS Config (not working)
VSTS Error
Visual Studio Config (working)
Do you guys have any ideas how to do that?
I had the same problem with deployment to smarterasp.net and was able to setup things for Web Deploy:
Your Dotnet Build task could create deployment package with necessary files like [YourProject].deploy.cmd, [YourProject].zip and etc. For this you could use next Arguments in your Build Task:
--configuration $(BuildConfiguration) /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\"
Add "Batch script" task and set path to your [YourProject].deploy.cmd in Path field and also in your Arguments:
/y /m:$(SmarterAspNet.PublishUrl) -AllowUntrusted /u:$(SmarterAspNet.UserName) /p:$(SmarterAspNet.Password) /a:Basic "-setParam:name='IIS Web Application Name',value='$(SmarterAspNet.SiteName)'" -enableRule:AppOffline
With this two main DevOps tasks I was able to deploy my app to smarterasp.net
About MSDeployAllTheThings task: I removed it because it is not needed for me anymore
Not familiar with smarterasp.net. But this should be an issue with that site.
If you run the same msdeploy command from your local machine manually, you will get the same error message. We didn't see this error when use the same command to deploy to some other host instead of smarterasp.net. And if you add "-verbose" in the command, you will get a more detailed information which indicates that the command failed to adding the virtual path:
When you deploy your project from VS, it use the manifest file and source folder directly rather than "package" method. So you'd either contact smarterasp.net for help or use the same deploy method as Visual Studio or some other deploy method like FTP.

MSBuild doesn't create a Web Deploy Package from command line with VS2017 PublishProfile

I use Visual Studio 2017 and have created some publish profiles. One of these is a CustomProfile1 Web Deploy Package, it works like charm when pressing Publish and i get:
- BuildTest.deploy.cmd
- BuildTest.deploy-readme.txt
- BuildTest.SetParameters.xml
- BuildTest.SourceManifest.xml
- BuildTest.zip
I have tried numerous experiments with msbuild but does not work to generate the files from command line
msbuild Buildtest.sln /p:DeployOnBuild=true /p:PublishProfile=CustomProfile1.pubxml
bin and obj folders are getting filled, but apprently CustomProfile1 is not triggered from command line shot?
msbuild -version
Microsoft (R) Build Engine version 4.6.1586.0
[Microsoft .NET Framework, version 4.0.30319.42000]
The command is probably confused as to which configuration you want to build,try adding
/p:configuration=Debug
you can also put Staging or Release depending on which configuration you want.

Dotnet Core publish to IIS from Mac

I want to publish my dotnet core app to IIS from mac. I use VS code for code writing and Dotnet Core 1.1 for publishing to local directory. (for example: bin/release/publish). There are compiled my files, ready to copy to IIS. On my IIS I currently have installed web deploy 3.6 and this is my VPS machine. Is there elegant way, how to copy files? The another way is using docker, but in this case I have the same problem. Generated docker file with docker publisher tool and I need to copy from mac os.
Thank you for your time.
From a terminal window navigate to the folder where your .csproj file is. From there run 'dotnet publish -c release'. A folder called publish will be created in bin/Release/netcoreappX.X. You can copy those files to the appropriate directory on your server. If you need help setting up IIS, follow the link below.
https://learn.microsoft.com/en-us/aspnet/core/publishing/iis
You can also run 'dotnet publish -h' to see all of the different arguments you can pass to the publish command.
Web Deploy (msdeploy.exe) seems to work in Mono, at least in WSL (Ubuntu 18.04). The tricky part is to extract the msi package somehow, which you can do easily on a Windows machine (you'll find the files in C:\Program Files\IIS\Microsoft Web Deploy V3).
Once you install Mono and obtain msdeploy.exe, just call the command, e.g.
mono msdeploy.exe -verb:sync -source:contentPath=/mnt/c/Data -dest:contentPath=test,ComputerName=https://example.com:8172/msdeploy.axd,UserName=WDeployAdmin,Password=PASSWORD,IncludeAcls=False,AuthType=Basic -enableRule:AppOffline -enableRule:DoNotDeleteRule -verbose -allowUntrusted:true
This lets you sync/copy the contents of /mnt/c/Data with the test web site in IIS on example.com with Web Deploy enabled.

Deploy ASP.NET Core without runtime and packages?

I'm doing build & deploy content in Visual Studio but this takes a lot of space (170 MB) because it contains runtime (dnx core clr) and all packages files.
Can I deploy web app to windows server and automatically install runtime and all packages on server for my web app?
You can scripted it to download the runtime as you instal it.
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
Dependencies can be then be dowloaded using the dnu restore command based on you project.json file.

Resources