How to modify default Web Deploy settings for a WebMatrix site? - deployment

Is there a way to tweak Web Deploy settings when it's used via WebMatrix publishing dialog?
For example, I would like to force WebMatrix using the 'checksum' method of determining which files will be synced when a publish operation is performed.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSDeployUseChecksum>true</MSDeployUseChecksum>
</PropertyGroup>
</Project>
Is there a way to make WebMatrix pickup that setting from a .wpp.targets file?

Related

AEM custom logs creation from scripts

we are automating the AEM configurations, we have a requirement for creating a custom log file. current Manual step followed is
login to AEM Felix console -> Sling -> log support ->Add new logger
parameters updated are log level, log file and logger.
is there a way to automate this log creation ? Please share your inputs.
Thanks in advance,
You can do this by configuring OSGI content nodes or by creating OSGI config files. For instance, I created an OSGI config node at this location:
/apps/cq/config.publish/org.apache.sling.commons.log.LogManager.factory.config-util.xml
That file has contents such as this:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.file="logs/util.log"
org.apache.sling.commons.log.level="debug"
org.apache.sling.commons.log.names="[com.myorg.commons.util.MyUtil,com.myorg.commons.util.OtherUtil]"
org.apache.sling.commons.log.pattern="\{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}"/>
Similarly, you can also do this for
/apps/cq/config.publish/org.apache.sling.commons.log.LogManager.factory.writer-util.xml
With contents such as
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.file="logs/util.log"
org.apache.sling.commons.log.file.buffered="{Boolean}false"
org.apache.sling.commons.log.file.number="5"
org.apache.sling.commons.log.file.size="20MB"/>
See https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/configuring-osgi.html for more details on how these files can be made specific to run modes.
When you install the package containing these nodes, since they are jcr:primaryType of sling:OsgiConfig they will automatically be picked up and configured in your environment (per run mode matching).

Does the 'MSDeployUseChecksum' option work with the FileSystem Publish method

I am trying to implement a deployment step using MSBuild with options DeployOnBuild and a PublishProfile with the WebPublishMethod set to FileSystem.
My PublishProfile looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<DeleteExistingFiles>False</DeleteExistingFiles>
<MSDeployUseChecksum>true</MSDeployUseChecksum>
</PropertyGroup>
</Project>
I am calling this from a build script that invokes MSBuild on individual projects and sets the PublishUrl depending on the build target (developer or deployment):
>msbuild.exe /p:DeployOnBuild=true /p:PublishProfile=c:\path\to\Profile.pubxml /p:SolutionDir=c:\path\to\solution /p:PublishUrl=c:\path\to\target /p:VisualStudioVersion=14.0 c:\path\to\project.csproj
The build process is intended to overlay project resources, including DLLs, over a third-party application. Due to behavior of NuGet restore, later versions of DLLs do not consistently have later change dates, so are being skipped during the deployment process. I have added the MSDeployUseChecksum option, which per documentation (here and here) should resolve the issue, but is not having an impact.
Does MSDeployUseChecksum work with the FileSystem deployment method? If yes, are any additional steps or settings required to make it work?

How do you upgrade the *.props included in a NuGet package?

I'm working on an internal NuGet package that adds a pre-build event.
It does this by specifying a build folder containing a MyPackage.props file per the documentation.
Here is the contents of the props file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PreBuildEvent>Some commands go here</PreBuildEvent>
</PropertyGroup>
</Project>
If the project has never had a pre-build event, the event is created. However, if there is an existing PerBuildEvent element in the csproj file, the new value does not get populated. I can get it to work if I open up the csproj file and manually delete the appropriate PropertyGroupElement:
<PropertyGroup>
<PreBuildEvent>Some command line stuff</PreBuildEvent>
</PropertyGroup>
However, I have to delete if from there, as just deleting the contents of the pre-build event in the UI does not allow the new value to be written.
I want to use the convention based method over doing this in install.ps1 because the documentation specifies:
[NuGet 3.x] This script will not be executed in projects managed by project.json
...and (I left this part out before) is there a way to do this when there is no csproj file?
What's going on?
I would suggest you do not use a prebuild event in your .props since I would expect that you do not want to overwrite an existing one in the project.
Instead you could look at using another target so that your logic runs before the build by using the BeforeTargets:
<Target Name="MyBeforeBuild" BeforeTargets="Build">
<Message Text="### MyBeforeBuild ###" Importance="high" />
</Target>
You may also want to look at using the DependsOnTargets attribute if you need your pre-build event to run after some other target.
<Target Name="MyTarget" DependsOnTargets="$(CoreCompileDependsOn)">
</Target>

MSBuild project deploy to local folder with config transformed

I'm having trouble trying to find the right way to use MSBuild to build a web project and output the project with only deployable files (i.e. no .cs, .csproj, .Debug.config etc.), but published to a local folder that I can then FTP, RoboCopy, (or whatever) to a secondary location.
The published output must have the Web.config file pre-transformed as per the specified configuration and the transformation config files (e.g. Web.Debug.config) not included in the output. I don't need any fancy publishing to IIS, database deployment or anything like that, I just want clean file system output that I can then test. Note that this cannot be done using visual tools as I want to run it as part of an automated build process.
I can generate a web deployment package, but I can't get WebDeploy to work because it doesn't seem to handle quoted command line options anymore (seems to be some kind of bug) and the directory structure has spaces, so I was hoping to accomplish the whole task using MSBuild, seeing as MSBuild seems to have native capacity to transform the config file (TransformXml), which is the only real bit of proper deployment functionality I'd be using.
Got it figured out eventually. The following build script does the trick:
<?xml version="1.0"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<PropertyGroup>
<OutputDir>obj\website-output</OutputDir>
</PropertyGroup>
<Target Name="PrepareDeploy">
<ItemGroup>
<DeployableFiles Include="App_Code/**/*.*;App_Data/**/*.*;Areas/**/Views/**/*.*;bin/**/*.*;Views/**/*.*;*.aspx;*.asax;*.html;*.htm;sitemap.xml;*.ico;*.png" Exclude="App_Data/**/*.log" />
</ItemGroup>
<RemoveDir ContinueOnError="true" Directories="$(OutputDir)" />
<MSBuild Projects="Website.csproj" />
<MakeDir ContinueOnError="true" Directories="$(OutputDir)" />
<Copy SourceFiles="#(DeployableFiles)" DestinationFiles="#(DeployableFiles->'$(OutputDir)\%(RelativeDir)%(Filename)%(Extension)')" />
<TransformXml Source="Web.config" Transform="Web.$(Configuration).config" Destination="$(OutputDir)\web.config" />
</Target>
</Project>

MSBuild: OutputPath directory is empty

I want to deploy my ASP.NET MVC site and have the following script.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\MyProjName\MyProjName.csproj"/>
<PropertyGroup>
<NewInstallDir>C:\DeployFolder\</NewInstallDir>
<BinDir>$(NewInstallDir)bin\</BinDir>
</PropertyGroup>
<Target Name="Build">
<MSBuild Projects="..\MySlnName.sln"
Properties="Configuration=Release;Platform=Any CPU;OutputPath=$(BinDir)" />
<Copy SourceFiles="#(Content->'..\MyProjName\%(RelativeDir)%(FileName)%(Extension)')"
DestinationFiles="#(Content->'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')" />
<Copy SourceFiles="#(None->'..\MyProjName\%(RelativeDir)%(FileName)%(Extension)')"
DestinationFiles="#(None->'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')" />
<MakeDir Directories="#(Folder->'$(NewInstallDir)%(RelativeDir)')" />
</Target>
</Project>
Main idea.
I copied binary to C:\DeployFolder (take structure of folder from sources). I build my dll to C:\DeployFolder\Bin (I don't have this folder in sources folder so I need separately copy this).
I run my script - all works instead of copy DLLs to OutputPath. Same scripts works for other asp.net mvc project. I have no idea what is wrong in this case.
I complete this issue with workaround but I would like to know what is wrong with this script.
The first thing I'd try is to replace your use of the deprecated $(OutputPath) with $(OutDir). From when I've seen this error, 9 times out of 10 it is due to a mismatch between the Platform/Configuration requested and how a particular project is actually defined. Take care to keep track of the discrepency between "Any CPU" (with a space) preferred by solution files and "AnyCPU" actually used inside project files for $(Platform). Some project wizards only set up an "x86" Platform or otherwise omit "AnyCPU" which can cause the OutputPath to be empty.
Beyond that, the approach of importing a project file and then building a solution (presumbably that includes the very same project" is a bit off center. Consider making the deployment changes you desire within the project file itself, through an import. You can either wire into the existing build targets at the right place, or perhaps add an additional target.