Skip to content

Codepolice

  • ⤫

Build, Git Commit, FTP When You Publish In Visual Studio

Posted by Judy Alvarez Posted on February 28, 2022March 3, 2022
0

For various reasons, I have a really weird build setup in Visual Studio. I just want to write this post so I can remember how it works now if I ever re-install my computer and something doesn’t work.

I use the regular publish feature in Visual Studio and deploy the code to a Website on my local IIS. This has always worked great and I don’t want to mess with firewalls and stuff to make it deploy to any remote site on my server. That just seems complicated.

My first modification to my .csproj file (that is more or less a regular MS Build file) is a command to open a text file where I write the message that I want to use for a git commit later on. The reason why I’m doing this is that I always forget to commit to Git and I couldn’t figure out any other way to force myself to enter something when I publish my app.

  <Target Name="BeforeBuild">
  <Exec Command="$(MSBuildProjectDirectory)/../commit-message.txt" />
  </Target>

When I close notepad or the default text editor you use the build continues and when the build is complete I execute this command that runs a WinSCP script to sync my local folder with the remote folder on my server. You also see my second command to commit to Git there but ignore that for now.

  <Target Name="CustomPostPublishActions" AfterTargets="MSDeployPublish">
    <Exec Command="$(PathToWinSCP) /script=$(MSBuildProjectDirectory)/../winscp-upload.txt" />
    <Exec Command="&quot;C:WindowsSystem32WindowsPowerShellv1.0powershell.exe&quot; -command &quot;&amp; {$(MSBuildProjectDirectory)/../git.ps1 '$(TargetPath)'}&quot;" />
  </Target>

The WinSCP script looks like this.

open serverbeach
synchronize remote C:DeployAlternativeTo /alternativeto/
exit

This works incredibly well.

At last, I execute a PowerShell command to commit to GitHub using that message I wrote earlier. I use Posh-Git for PowerShell. My PowerShell script looks like this.

$message = Get-Content ../commit-message.txt
git commit -a -m "$message"

Well, that’s it. I understand I don’t explain this in much detail but as I said before I think this scenario is very unique to me and my situation. But feel free to ask any questions if you have similar needs.

Categories: JavascriptTagged: .net core mvc vs web api, .net core vs mvc 5, .net framework mvc, .net mvc interview questions for 2 years experience, asp .net core vs mvc, asp dot net mvc tutorial, asp net core mvc multiple models in one view, asp net mvc 4 tutorial step by step, asp net mvc 5 angularjs template, asp net mvc cloud hosting, asp net mvc https, asp net mvc layout templates free download, asp net mvc overview, asp net mvc pipeline, asp net mvc razor, asp net mvc routing examples, asp net mvc vs webforms, asp net with mvc training, developing asp net mvc 4 web applications, difference between .net mvc and .net core, download asp net mvc 5, how to implement lazy loading in asp net mvc, learn asp net mvc step by step, learn net mvc, mvc architecture net, mvc in .net, mvc model in asp net, net mvc development, professional asp net mvc 5 pdf, web push notifications asp net mvc

Post navigation

Previous Previous post: Request.Files is Empty in a Web Forms Application
Next Next post: Query the MySQL / WordPress Database from an ASP.NET site

Related Posts

  • Package efficiency and dependency hygiene

    #​752 — September 12, 2025 Read on the Web If you have any interest in music and being able to render music or generate music with JavaScript, be sure to check out the very end of this issue where we’ve dedicated an entire section to the topic 🙂__Your editor, Peter Cooper JavaScript Weekly How to Keep

    Posted by Posted on September 12, 2025
    0
  • A significant supply chain attack on the npm ecosystem

    #​592 — September 9, 2025 Read on the Web A Major Supply Chain Attack Hits the npm Ecosystem — In July, Socket warned us about a phishing campaign targeting npm package publishers. Sadly, a prolific package author (among others, like DuckDB, who explain how the attack worked on them) fell victim to the scam, resulting

    Posted by Posted on September 9, 2025
    0
  • Why browsers throttle JavaScript timers (and what to do about it)

    #​751 — September 5, 2025 Read on the Web JavaScript Weekly Mediabunny: A Complete Media Toolkit for JavaScript — Supporting both browsers and Node.js, this library lets you read, write and convert popular media file formats (e.g. MP4, MP3, and more) without needing to lean on dependencies like FFmpeg. You can make thumbnails, extract metadata,

    Posted by Posted on September 5, 2025
    0
  • The latest on Oracle’s hold on JavaScript

    #​750 — August 29, 2025 Read on the Web JavaScript Weekly An Illustrated Guide to Big O and Time Complexity — A fantastic JavaScript-oriented, interactive, visual essay about Big O notation and its role in describing algorithmic complexity. This is a beautiful bit of work, even if you’re already wise to O(log n) and O(n^2).

    Posted by Posted on August 29, 2025
    0
  • The productivity benefits from type stripping

    #​591 — August 26, 2025 Read on the Web How We Migrated Our Rush.js Monorepo to Node Type Stripping — Since v23.6 (and in LTS since v22.18.0), Node has supported running (most) TypeScript code by stripping the types out first. The Calm team was excited about the potential for improving productivity and DX, and set

    Posted by Posted on August 26, 2025
    0
  • We still love jQuery

    #​749 — August 22, 2025 Read on the Web ☀️ We’re back after a week off, though I’m starting to think we should have taken two weeks off as it’s been quite quiet in JavaScript-land this August! Nevertheless, we still have a full issue for you today, so let’s get on to it.. 😉__Peter Cooper, your

    Posted by Posted on August 22, 2025
    0
Judy Alvarez

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Codepolice

  • Github
  • Atlassian
  • Flatlogic
  • Xero
  • Jetbrains
  • Figma
  • Package efficiency and dependency hygiene
  • A significant supply chain attack on the npm ecosystem
  • Why browsers throttle JavaScript timers (and what to do about it)
  • The latest on Oracle’s hold on JavaScript
  • The productivity benefits from type stripping
https://flatlogic.com/generator
COPYRIGHT © 2025 - Codepolice