Powershell & IIS (edit)
1) Tìm đường dẫn của MSBuild.exe
Tìm đường dẫn của MSBuild.exe? Vào Powershell, gõ lệnh sau:
&"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
Tìm đường dẫn của devenv.exe hoặc Installer\setup.exe? Vào Powershell, gõ lệnh sau:
&"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products *
2) Dùng MSBuild để BUILD & DEPLOY ứng dụng ASP.NET hoặc ASP.NET Core
Using command-line MSBuild tool to build .Net Project/Solution | Sparekh (HAY)
Build and Deploy using MSBuild command-line tool | Sparekh (HAY)
Use MSBuild.exe to build specific targets in solutions - Visual Studio | Microsoft Docs
MSBuild publish dotnet core application - Stack Overflow (HAY)
Build a solution:
msbuild NameOfYourSoution.sln
Build a specific project
msbuild NameOfYourProject.csproj
The project could be c# or vb or any other .Net compatible project.
Both of the above commands will build a debug version of your solution/project. What if you want to specify Release Configuration or other Configuration you created?
This can be easily handled with MSBuild properties arguments.
Specifying MSBuild Configuration parameter:
msbuild NameOfYourProject.csproj /p:Configuration=Release
Rebuilding your project with MSBuild command-line
This can be achieved with /t: argument where t stands for Targets
msbuild NameOfYourProject.csproj /t:rebuild
Cleaning your Solution/Project with MSBuild command-line
msbuild NameOfYourSolution.sln /t:clean
Build & Deploy
Here is the all-in one Build and Deploy msbuild command. You can extend it to your liking by adding more parameters.
msbuild YourProject.csproj /P:Configuration=Release /P:DeployOnBuild=True /P:DeployTarget=MsDeployPublish /P:MsDeployServiceUrl=https://yourserver-address/msdeploy.axd /P:AllowUntrustedCertificate=True /P:MSDeployPublishMethod=WMSvc /P:CreatePackageOnPublish=True /P:UserName=username /P:Password=password /P:DeployIISAppPath="yoursite.com"
3) Deploy using public profiles
Visual Studio publish profiles (.pubxml) for ASP.NET Core app deployment | Microsoft Docs
Visual Studio publish profiles for ASP.NET Core app deployment
VS_Publish_Profiles_1.1.pdf (windows.net)
Guide to use the dotnet publish
docs/dotnet-publish.md at main · dotnet/docs · GitHub
Publish on Azure DevOps
Publish a self-contained .NET Core 3.1 app on Azure DevOps | elmah.io
4) Dùng PowerShell để tạo Website trong IIS (Web Server)
https://octopus.com/blog/iis-powershell (HAY HAY HAY)
https://petri.com/enable-iis-remote-management-powershell-create-new-sites
Import-Module WebAdministration
Set-Location IIS:\AppPools\
Get-ChildItem
DefaultAppPool
$Folder = New-Item C:\inetpub\wwwroot\test –ItemType directory
$Website = New-Website -Name "test" -Port 80 -PhysicalPath $Folder -ApplicationPool DefaultAppPool
Set-ItemProperty 'IIS:\Sites\test' applicationPool DefaultAppPool