Open julealgon opened 1 month ago
Hmm - I've not encountered this myself. There are some examples of how to publish manually or with CI/CD in https://github.com/CZEMacLeod/MSBuild.SDK.SystemWeb/issues/21#issuecomment-1478474537
You might be able to fix the ordering you are talking about with
<PropertyGroup>
<PipelineCollectFilesPhaseDependsOn>
$(PipelineCollectFilesPhaseDependsOn);
MvcBuildViews;
</PipelineCollectFilesPhaseDependsOn>
</PropertyGroup>
If this fixes things, then I would think that a PR to add this to the SDK would be in order.
You might also try
msbuild /p:Configuration=Release /p:DeployOnBuild=true /p:PrecompileBeforePublish=true /p:MvcBuildViews=false
I realized after looking a bit further into this that we don't really need to have the MvcBuildViews
flag at the point of publish, as we are already building the project in a previous step with that flag enabled (by default).
So I worked around this by adding <MvcBuildViews>false</MvcBuildViews>
to my publish profile.
You might also try
msbuild /p:Configuration=Release /p:DeployOnBuild=true /p:PrecompileBeforePublish=true /p:MvcBuildViews=false
As I understand it, PrecompileBeforePublish
is a different behavior, that optimizes for first access on the server. We are not (yet) using this flag on our deployment, but I'll definitely look into it.
For now, the only reason we've been using the standard MvcBuildViews
was for PR validation purposes (so it would fail if any additional error was detected on views after dynamic compilation).
@julealgon
You do understand correctly about the PrecompileBeforePublish
and related properties will perform an AspNet Compilation immediately before and include that output into the publish artifacts. Once you are using the precompile option having the MvcBuildViews disabled is even preferred because running both would just run the AspNet Compiler twice.
If you decide that while you are investigating the PrecompileBeforePublish
you would like to retain the ability to fail the build process on any AspNet Runtime Compilation errors, you can alter your publish profile to set the "destination" of the publish output to anywhere outside the project directory (the name of this property changes between Folder and WebDeploy profiles so I'm not including it).
I'm playing around with switching our deployment process from a "raw" file copy of build outputs, to a more proper "publish"-based approach, where we first publish to a folder and then copy those contents instead. One of the things I want to tap into with this change is the native XML transform step, which we currently cannot use as it only runs on publish.
However, I noticed that when I try to publish in
Release
mode, the contents of thebin/obj/Package
folder (the standard place where publish outputs are placed) is empty.I'm running the following simple commandline:
I noticed that if I executed the exact same command, but using
Debug
configuration, the files were output just fine.After analyzing the logs, I noticed that the publish results were being cleaned by the aspnet compilation target, which appears to be running after the publishing step. This of course is triggered by the
MvcBuildViews
flag, which istrue
by default only inRelease
mode.At first glance, this makes little sense to me: shouldn't aspnet compilation be happening before packaging, so that the extra compiled bits are included in the publish package?
Here is a slightly redacted version of the MSBuild logs from one of our affected projects, starting after the
CoreCompile
target:The package contents are generated in the
PackageUsingManifest
target, but right after that,CleanupForBuildMvcViews
is executed and deletes all the files it generates.I found a similar problem described here:
But in that case, the person had the
MvcBuildViews
target declared in their own project, which is not the case with this SDK, where that target (AFAIK) is part of the SDK itself.Am I missing something obvious here, or is there an issue in the SDK that should be fixed so that
MvcBuildViews
(aspnet compiler dynamic compilation) takes place before the standard publishing targets do?Is this SDK supposed to work with the
DeployOnBuild
MSBuild flag? Or should I actually be looking into a different deployment approach altogether?