0

When I build a web project from command-line using msbuild and no special parameters, it seems to build just fine, including calling an nswag task to build TS files.

When I build the same web project with the /p:DeployOnBuild=true parameter and the /p:PublishProfile parameter set, nswag is not called at all, and the build fails because none of the TS files were built.

Isn't using the DeployOnBuild parameter additive? Shouldn't any build tasks specified in the csproj file still get executed?

Kevin McDowell
  • 532
  • 6
  • 20

1 Answers1

1

Using the Structured Log Viewer for MSBuild I was able to determine why MSBuild seemed to be skipping the NSwag task specified in my csproj file when DeployOnBuild=true.

Build order matters!

In our project we build a client TS file at build time and then at the end run yarn tsc to build out all of the JS files.

Wnen we add DeployOnBuild=true, early in the build process, it attempts to copy the JS files to the package folder. But because client TS file hadn't been built yet and the JS file created from it, the build was failing and never even getting to the NSwag command.

Kevin McDowell
  • 532
  • 6
  • 20
  • Since you have a workaround, I suggest you could [mark your own answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work):) – Mr Qian Feb 26 '21 at 02:19