I have a website (not a web application) and I want to publish it from the command prompt in the same directory every night.
I don't want to use build automation tools like TeamCity, TFS, or third-party tools like Nant - it should be done with MSBuild
. How can I do this?
Update: in the Publish window the only option that should be checked is Use Fixed naming and single page assemblies
.
Builds the targets in the project file that you specify. If you don't specify a project file, MSBuild searches the current working directory for a file name extension that ends in proj and uses that file. You can also specify a Visual Studio solution file for this argument.
For example, the path to MSBuild.exe installed with Visual Studio 2019 Community is C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe You can also use the following PowerShell module to locate MSBuild: vssetup.
Description. The dotnet msbuild command allows access to a fully functional MSBuild. The command has the exact same capabilities as the existing MSBuild command-line client for SDK-style projects only. The options are all the same.
From your comment, your web project is a web site project and not a web application project.
In this case, 'Publish' target can not be the option but 'AspNetCompiler' is the solution.
Create an xml file with below content and call it from MSBuild.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="PrecompileWeb"> <AspNetCompiler VirtualPath="/MyWebSite" PhysicalPath="c:\inetpub\wwwroot\MyWebSite\" TargetPath="c:\precompiledweb\MyWebSite\" Force="true" Debug="true" FixedNames="True" /> </Target> </Project>
Reference to this task is here and you can configure all your un/check options.
FixedName="True" equals the checking of 'use fixed naming and single page...' option.
Then you call this file from MSBuild instead of the solution file.
MSBuild your.xml /p:Configuration=<Debug/Release>
As long as your class libraries are referenced by your web site project, they'll be built together.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With