{"id":143,"date":"2022-09-26T11:07:48","date_gmt":"2022-09-26T03:07:48","guid":{"rendered":"https:\/\/aabirtech.com\/shiblenomanblog\/?p=143"},"modified":"2022-09-26T11:08:30","modified_gmt":"2022-09-26T03:08:30","slug":"net-publish-using-powershell","status":"publish","type":"post","link":"https:\/\/aabirtech.com\/shiblenomanblog\/2022\/09\/26\/net-publish-using-powershell\/","title":{"rendered":".Net Publish Using PowerShell"},"content":{"rendered":"\n<p>Sometimes we want to publish project using PowerShell rather then using Visual Studio Publish feature. I wanted to published all projects of the solutions in one folder. Below PowerShell command will published our projects in __DEPLOY__ folder as an example. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd src\n$paths = Get-ChildItem -include *.csproj -Recurse\nforeach($pathobject in $paths)\n{\n     cd $pathobject.directory.fullName\n     dotnet publish -o ..\\..\\__DEPLOY__\\Program\n}\ncd ..\\..<\/code><\/pre>\n\n\n\n<p>Save this code as PowerShell script with extension of ps1. Run this script from VS, we need to open VS in elevated permission, open &#8220;Developer PowerShell&#8221; navigate to the script folder and run the script. <br>You may face an error with error message <br>&#8220;FullyQualifiedErrorId : UnauthorizedAccess&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"682\" height=\"61\" src=\"https:\/\/aabirtech.com\/shiblenomanblog\/wp-content\/uploads\/2022\/09\/image.png\" alt=\"\" class=\"wp-image-144\" srcset=\"https:\/\/aabirtech.com\/shiblenomanblog\/wp-content\/uploads\/2022\/09\/image.png 682w, https:\/\/aabirtech.com\/shiblenomanblog\/wp-content\/uploads\/2022\/09\/image-300x27.png 300w\" sizes=\"auto, (max-width: 682px) 100vw, 682px\" \/><\/figure>\n\n\n\n<p>To resolve this error run this command to by pass security exception <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass<\/code><\/pre>\n\n\n\n<p>Run the PowerShell Script again, it should run it without any issue. And all you published files and folder should be in &#8220;__DEPLOY__&#8221; folder. <br><br>Happy Hacking \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we want to publish project using PowerShell rather then using Visual Studio Publish feature. I wanted to published all projects of the solutions in one folder. Below PowerShell command will published our projects in __DEPLOY__ folder as an example. Save this code as PowerShell script with extension of ps1. Run this script from VS, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-143","post","type-post","status-publish","format-standard","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/posts\/143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/comments?post=143"}],"version-history":[{"count":2,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/posts\/143\/revisions"}],"predecessor-version":[{"id":146,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/posts\/143\/revisions\/146"}],"wp:attachment":[{"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/media?parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/categories?post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aabirtech.com\/shiblenomanblog\/wp-json\/wp\/v2\/tags?post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}