Skip to main content

Publish the application

Visual Studio publish produces a folder you copy to IIS. Damsy ERP uses a dedicated profile MVC_PUBLISH tuned for VPS deployment: Release configuration, full view files (no precompile), and a clean output directory each time.

Introduction​

Publishing compiles the solution in Release mode, applies Web.Release.config transforms, and copies web content to a target folder. Unlike SDK-style projects, classic ASP.NET MVC requires explicit <Content Include="..."> entries in the .csproj for many static files and views — files missing from the project file are silently omitted from publish output.

Purpose​

Generate a complete, IIS-ready folder that includes assemblies, Razor views, CSS/JS, Crystal viewer assets, and transformed configuration — without the broken partial deployments that precompiled publish often causes.

When to use​

  • Every production or VPS deployment
  • Before copying files to C:\inetpub\wwwroot\damsy_erp
  • After adding new .cshtml, .css, or .js files to the UI project

For IIS binding and app pool setup, continue to Deploy to IIS.

How it works​

The publish profile lives at:

DamsyERP.UI/Properties/PublishProfiles/MVC_PUBLISH.pubxml

Key settings:

SettingValueWhy
LastUsedBuildConfigurationReleaseOptimized binaries + transforms
WebPublishMethodFileSystemFolder copy deploy
DeleteExistingFilesTrueAvoid stale DLLs and orphaned views
PrecompileBeforePublishFalsePrecompile breaks views/assets on IIS
publishUrlDev machine pathChange or override per operator

Example profile output path:

C:\Users\Thinkpad\Music\Publish\damsy_erp

Production IIS target (typical):

C:\inetpub\wwwroot\damsy_erp

Step-by-step — Publish from Visual Studio​

Step 1 — Open the publish profile​

  1. Set configuration to Release (toolbar dropdown).
  2. Right-click DamsyERP.UI → Publish.
  3. Select profile MVC_PUBLISH (or import the .pubxml from Properties/PublishProfiles/).

Step 2 — Run publish​

  1. Confirm Configuration: Release.
  2. Click Publish.
  3. Wait for Publish succeeded in the Output window.
info

PrecompileBeforePublish=False is intentional. Precompiled publish has caused missing partial views and static asset issues on IIS for this solution.

Step 3 — Verify the publish folder​

Before copying to the server, confirm critical paths exist:

publish/damsy_erp/
├── bin/DamsyERP.UI.dll
├── Web.config
├── Views/Dashboard/Index.cshtml
├── Areas/Registration/Views/Shared/_UnitPermissionS.cshtml
├── app-assets/css/shell-modern.css
├── app-assets/css/sidebar-unified.css
├── app-assets/css/administration-dashboard.css
└── crystalreportviewers13/

Use Windows Search or PowerShell:

Test-Path "C:\Users\Thinkpad\Music\Publish\damsy_erp\app-assets\css\shell-modern.css"

Step 4 — Copy to IIS​

Copy the entire folder contents to Deploy to IIS target path, then recycle the app pool.

The csproj Content Include gotcha​

New files added to disk are not automatically published. They must appear in DamsyERP.UI.csproj:

<Content Include="app-assets\css\shell-modern.css" />
<Content Include="Areas\Registration\Views\Shared\_UnitPermissionS.cshtml" />

Symptoms of missing includes​

Missing file typeSymptom
Module CSSDashboard looks unstyled; "old" flat UI
Shared partialThe partial view '_UnitPermissionS' was not found
Area view404 or HandleError after navigation

Fix workflow​

  1. In Solution Explorer, Show All Files.
  2. Right-click the missing file → Include in Project (adds Content entry).
  3. Rebuild and Publish again.
  4. Re-verify the publish folder before IIS copy.
warning

A successful publish dialog does not guarantee every file on disk was included. Always spot-check new assets in the output folder.

Examples​

Example — Publish via MSBuild (CI or script)​

msbuild DamsyERP.UI\DamsyERP.UI.csproj `
/p:DeployOnBuild=true `
/p:PublishProfile=MVC_PUBLISH `
/p:Configuration=Release

Example — Quick CSS audit after publish​

$root = "C:\Users\Thinkpad\Music\Publish\damsy_erp\app-assets\css"
Get-ChildItem $root -Filter "*dashboard*.css" | Select-Object Name

Example — Adding a new stylesheet​

  1. Add app-assets/css/payroll-dashboard-v2.css on disk.
  2. Include in .csproj as <Content Include="app-assets\css\payroll-dashboard-v2.css" />.
  3. Reference in layout with cache-bust query: ?v=20250720.
  4. Publish and confirm file under publish root.

Important notes​

  • DeleteExistingFiles=True removes leftover files from prior deploys — good for consistency; ensure you do not store uploads only under the publish tree without backup.
  • Connection strings on the server should be edited in the deployed Web.config, not only in source control.
  • Crystal Reports .rpt files and viewer JS must publish with the site; verify under Areas/*/...Reports/ and crystalreportviewers13/.
  • Layouts use cache-busting query strings on CSS — browsers may still cache aggressively; hard-refresh after deploy.

Common mistakes​

MistakeConsequence
Publishing with Debug configurationNo Release transforms; debug=true
Using a profile with PrecompileBeforePublish=TrueBroken or missing views on IIS
Assuming git pull updates IISMust publish + copy + recycle
Forgetting .csproj include for new .cshtmlRuntime partial/view not found
Copying only changed DLLsStale views/CSS remain or mismatch

Next steps​

  1. Apply Release configuration expectations on the server.
  2. Deploy to IIS and grant IIS APPPOOL\... SQL access.
  3. Log in against a configured database — Seed scripts.