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

  • TypeScript and JavaScript dominate on GitHub in 2025

    #​759 — October 31, 2025 Read on the Web JavaScript Weekly Directives and the Platform Boundary — First there was the “use strict” directive to opt in to strict mode in JavaScript, but now you’ll encounter use client, use server, React’s new use no memo, and more, and they’re not standard JS features at all.

    Posted by Posted on October 31, 2025
    0
  • The reality of porting Deno code to Node

    #​598 — October 28, 2025 Read on the Web Awesome Node: Over 500 Curated Packages, Resources and Links — It’s been more than four years since we linked to Sindre’s handy resource, but it continues to get updates and tweaks (and, if you want, you can contribute a submission too – though the bar is

    Posted by Posted on October 28, 2025
    0
  • Vitest 4.0 and Next.js 16

    #​758 — October 24, 2025 Read on the Web JavaScript Weekly Vitest 4.0 Released: The Vite-Native Testing Framework — The Vite-powered, Jest-compatible testing framework introduces visual regression testing, makes its ‘Browser Mode’ stable (for running tests in a browser directly), adds Playwright Traces support, and more. Still unsure? You can compare it with other test

    Posted by Posted on October 24, 2025
    0
  • Node.js 25.0 arrives

    #​597 — October 21, 2025 Read on the Web Node.js v25.0.0 (Current) Released — The latest cutting edge version of Node has arrived with Web Storage enabled by default, JSON.stringify perf improvements, a new –allow-net option in the permission model, built-in Uint8Array base64/hex conversion, and WebAssembly and JIT optimizations. As shown in the diagram above, this

    Posted by Posted on October 21, 2025
    0
  • A Bun-believable release that isn’t half-baked

    #​757 — October 17, 2025 Read on the Web JavaScript Weekly Bun 1.3: The Full-Stack JavaScript Runtime — Arriving a few hours after last week’s issue (natch!) Bun 1.3 remains the big news of the past week. Bun is a performance and DX-focused JavaScriptCore-powered runtime which, with v1.3, balances being a drop-in Node.js replacement with

    Posted by Posted on October 17, 2025
    0
  • Bringing Python apps into Node

    #​596 — October 14, 2025 Read on the Web 📂 A Modern Guide to Reading and Writing Files in Node — A comprehensive guide to various methods for working with files, from promise-based methods through to working with streams, processing files concurrently, using file handles, and memory-efficient techniques. Luciano Mammino A Way to Integrate Python ASGI with Node.js

    Posted by Posted on October 14, 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
  • TypeScript and JavaScript dominate on GitHub in 2025
  • The reality of porting Deno code to Node
  • Vitest 4.0 and Next.js 16
  • Node.js 25.0 arrives
  • A Bun-believable release that isn’t half-baked
https://flatlogic.com/generator
COPYRIGHT © 2025 - Codepolice