You can easily compile your. NET application by using PS Plus MSBuild, and you can publish it to your disk and deploy a very good example!
We add a Hello website in C drive, the solution name is Hello.sln, its website is hello.csproj, now use this script to generate this website and publish this website!
$ErrorActionPreference ='Stop'# Environment Helpers------------------------------------Function Get-Msbuildpath () {$msBuildRegPath="hklm:\software\microsoft\msbuild\toolsversions\14.0"$msBuildPathRegItem= Get-itemproperty $msBuildRegPath-name"MSBuildToolsPath"$msBuildPath= $msBuildPathRegItem. MSBuildToolsPath +"MSBuild.exe" return$msBuildPath}# Environment Variables----------------------------------$global _builddirpath= get-Location$global_msbuildpath= get-Msbuildpath$global_solutionpath="$global _builddirpath"$global _solutionfilepath="$global _solutionpath\hello.sln"$global _nugetpath="$global _builddirpath\tools\nuget.exe"# Install NuGet Packages---------------------------------Function Install-solutionpackages () {IEX"$global _nugetpath restore $global _solutionfilepath"}# compilefunction Compile-publish-Project () {IEX-command"& ' $global _msbuildpath ' $project _path '/p:configuration=release/p:webprojectoutputdir=c:\publish\hello/p : Outputpath=c:\publish\hello\bin"}install-Solutionpackagescompile-publish-project
The last generated site results are
This feature is very necessary for automated deployment, and uncle will do further research and optimization of this piece of content!
Thank you!
powershell~ Publish your MVC site