Umbraco & TFS - Including hidden files - visual-studio-2012

I have an umbraco 6.* site set up in VS2012 and am using TFS for source control.
If I add templates, media items etc to the umbraco site through the umbraco backend the new files are not automatically included in the solution and I have to manually include the files so that they can be checked in to source control.
This can become quickly unmanageable when installing packages etc. or anything that creates a lot of files throughout different folder locations.
Does anyone have a solution to guarantee all files are checked into source control?
Changing source control is not an option.
Thanks

I came across this article which explains how to 'blanket' include files or folders in a .csproj file. In a nutshell you can add the following references:
<Content Include="Path\To\Folder\**" />
<Content Include="Path\To\Folder\*.*" />
<Content Include="Path\To\Folder\*.jpg" >
So in the case of Umbraco you will first need to exclude the following folders from the project:
/umbraco
/umbraco_client
/media
/masterpages
/views
/macroscripts
/xslt
then open up the .csproj file in a test editor and add:
<Content Include="umbraco\**" />
<Content Include="umbraco_client\**" />
<Content Include="media\**" />
<Content Include="masterpages\**" />
<Content Include="views\**" />
<Content Include="macroscripts\**" />
<Content Include="xslt\**" />
Save it, and then in VS reload your project.

Related

Bot Framework publish and deploy to Azure from VS 2019 - missing files

I wrote a C# web bot using external resources (.lg and .dialog files), which - as I think - are not deployed along with the code. I deploy from VS2019, right click and "publish / azure / Azure App Service (windows 10)" into an already existing app service.
Which are the worst that asks almost nothing, I cant see how I can add files to the publishment package. The bot wont work on azure portal, after several hours I found where are the log files, and see that it says cant open the .lg file because it is missing.
In the adaptive dialog constructor:
this.Generator = new TemplateEngineLanguageGenerator(Templates.ParseFile(Configuration["Dialog.Templates.Root"]));
in my appsettings.json:
"Dialog.Templates.Root": "Templates/root-dialog-templates.lg",
How can I add files to copy along during the deployment?
Thanks for any suggestion and help!
You can include something like this sample in your .csproj file, assuming your .lg, .dialog files are under the Dialogs folder
<ItemGroup>
<None Remove="Dialogs\**\*.lg" />
<None Remove="Dialogs\**\*.dialog" />
</ItemGroup>
<ItemGroup>
<Content Include="Dialogs\**\*.lg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Dialogs\**\*.dialog">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
This way you'll find the deployed files in the same folder relative to the project's content root, which is usually current directory.

How to add extra files to the package that is generated by msbuild called by an Azure Resource Group Project in Visual Studio

So I have a solution made up of a web project and an Azure Resource Group project much like what is described here: https://blogs.technet.microsoft.com/georgewallace/2015/05/10/deploying-a-website-with-content-through-visual-studio-with-resource-groups/
The issue I am having is that the web project needs to include some EXTRA files in its bin directory in order to function. Now through the normal package process on the web project itself I accomplish this by adding a custom target and hook into CopyAllFilesToSingleFolderforPackageDependsOn, like:
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="bin\SlimKIA.WebApi.xml" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\SlimKIA.WebApi.xml</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
And when I right-click on the web project and say "publish" to, say, a file system, my file gets included. All is well and good.
The problem is that this does not happen when I deploy from the deployment project. I have an MsDeploy resource that does its own thing. I need to somehow do my CustomCollectFiles from within this project.
Anyone have any ideas as to how to accomplish this? Without this I am unable to automate the deployment of my solution to Azure.
Thanks!
On a whim I ended up doing this:
<PropertyGroup>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
The key being the CopyAllFilesToSingleFolderForMsdeployDependsOn instead of CopyAllFilesToSingleFolderForPackageDependsOn. Just changing this did the trick, which I guess triggered msdeploy to include the custom target.

How to rename web.config transforms

I am working in an ASP.net MVC 5 solution in Visual Studio 2015. I have the following web.config
How do I rename those to be
Web.Integration.config
Web.Staging.config
Web.Production.config
When I right-click on those, I don't get a rename option!
You can copy the files, rename them and manually edit the .csproj file to include them (replacing the generated ones) like below:
<Content Include="Web.Integration.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Staging.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</Content>
<Content Include="Web.Production.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</Content>
Unfortunatelly I did not find a way to acomplish this through visual studio.
This is the third time I've set one of these up in a project and I get stuck every time. The key is that the config transform files are linked to the named build configurations.
If you go to Build > Configuration Manager... and select the Active solution configuration drop-down you can add new build names. Afterward you can right-click your web.config and Add Config Transform, which asks no questions and just creates one transform for each build.
Renaming an existing build didn't work, it still generated a transform with the original name, but you can delete builds or selectively delete the transform files.
If you are using the extension Configuration Transform go to Build > Configuration Manager and find the Configuration dropdown for the project of which you want to change the app config. You can then select the edit and rename the build configurations for that project. Then re-run the Configuration Transform tool and it will generate app configs using the names you provided in the build configuration settings.
What I found worked for me is to just delete the Debug and Release, and then create new ones. Saved me a lot of worry with dangling references and build errors and the like

Azure sitesroot does not contain all deployed files

I'm deploying a web role to Azure using VS 2013. I added a Contents element to my .csdef file to deploy extra files that are not included in the Azure deployment package like this:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="..." xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-06.2.4">
<WebRole name="..." vmsize="Small">
<!-- snip -->
<Contents>
<Content destination="bin/">
<SourceDirectory path="C:\...\bin"/>
</Content>
</Contents>
</WebRole>
</ServiceDefinition>
When the package is deployed, I can see the extra files being put in the approot folder on the instance's F: drive. However, these files are never deployed to the sitesroot\0 folder, from which the web role seems to run. Because these extra files are assemblies that are to be loaded dynamically, I would like them to be together with the application's other assemblies.
Is this behavior intentional or am I doing something wrong? There doesn't seem to be much information about this online.
I ended up using the Content element in the end, but with a different destination path, pointing to the sitesroot folder. It's a bit of a hack, but at least it works without diving into MSBuild or manual packaging of the deployment.
<ServiceDefinition name="..." xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-06.2.4">
<WebRole name="..." vmsize="Small">
<!-- snip -->
<Contents>
<Content destination="..\sitesroot\0\bin">
<SourceDirectory path="C:\...\bin" />
</Content>
</Contents>
</WebRole>
</ServiceDefinition>
The behaviour is as per the documentation which states that the deployed location is relative to the Role's APPROOT (the behaviour you are seeing).
If you want them deployed into your site's bin folder you need to package them as part of your Visual Studio solution.
You can add a DLL to your root directory of a project (Add -> Existing Item). If you take that DLL and change the Build Action set to Content and the Copy to Output Directory set to Copy Always then I think this will make sure that the DLL ends up being in your BIN folder, or equiv.
An example of what I've done in the past:
Two projects in a Solution named:
DependenciesProject (Class Library)
WebProject (MVC App)
I had a need where some specific DLLs that needed to be bundled into the compiled package were included but the specific DLL that would be used would change based on my compiled targets (x64 vs x86). The solution we chose to go with was to have the DependenciesProject do what I described for you to do above and we modified the .csproj file to change the path to these native DLLs based on the target specified at compile-time (we disabled Any CPU).
So the DependenciesProject had these DLLs in the root directory (with that .csproj having some tweaks for dynamic paths to the DLLs that existed in our Nuget packages folder) and the DLLs in the Solution Explorer had the Build Action set to Content and the Copy to Output Directory set to Copy Always. This means whenever a DependenciesProject.dll file was compiled, it would move the other DLLs into the same output folder as that .DLL file.
Now WebProject project would have a Project Reference to DependenciesProject. This means every time I try to compile WebProject, it will first compile DependenciesProject and then copy its output folder into the WebProject's output folder.
The end result: DependenciesProject.dll as well as MySpecial.dll existed with my web application every time I needed it.
Does this help?

AjaxMin not working on Azure site

I am using Microsoft's AjaxMin to minify javascript on my website, which is hosted by Azure. I am using a BuildTask to automatically minify javascript at run time. This build task is specified in the .csproj file.
The process is working on my local environment, however, it does not work when I deploy to my Azure site. The azure site throws 404: file not found errors, when i try to reference the minified version of .js files.
Is it possible to use build tasks on an Azure site? Is there anything I am missing? I have made sure not to include the .min.js files in source control as this (http://www.asp.net/ajaxlibrary/AjaxMinQuickStart.ashx) tutorial suggests, but I am wondering if there is anything specific to Azure that I need to set up.
Thanks!
I've got this working properly in my projects. I'll tell you how I did it, though this may not be the simplest or most straightforward way.
Before we get started, it's helpful to be able to check if your minified files are included in the Azure deployment package without actually deploying. It's pretty easy to do. The .cspkg file is actually a zip-formatted file, so you can open it with any zip archiver. (I like to use 7Zip for this because the right-click -> Open Archive command doesn't require you to rename the file, but you could use Windows Explorer, WinRAR, etc.) Inside the .cspkg you'll see another large file with a .cssx extension. That's a zip file too. Inside of the .cssx you'll find a sitesroot folder with a subdirectory for each website you're deploying, which will contain all your actual website files. So you can poke around in there and see what files are being deployed to Azure.
First, try editing the project file for your web project (the one that contains all the Javascript/CSS files). You can use Notepad, or in Visual Studio right-click the project, select "Unload Project", then right-click again and select "Edit ". Inside the project file, insert a section like this:
<ItemGroup>
<!-- Copy over all the minified CSS & JS to the output directory-->
<Content Include="**\*.min.css" />
<Content Include="**\*.min.js" />
</ItemGroup>
Then reload the project, repackage it, and see if your files are included in the .cspkg file. If they are, then you're done.
If not, there are a couple other things to check. Your minification might not be running at the right build stage. My minification target looks like this:
<Target Name="PrepWebApp" Condition="$(Configuration)=='Release'" AfterTargets="AfterBuild">
If that's still not working and your Web Role has multiple Sites and/or Virtual Applications in it, it's possible that the packaging steps are not running for all of the sites. So when you go to package your project for deployment to Azure, it may still not be running the minification step (along with the web.config transformations, and some other things). If that's the case, see this blog post for a way to fix it.
Just in case that blog post goes away, I'll copy the most relevant bit here. You would put this in the .ccproj file for your web role (with appropriate bits changed to match your project structure):
<PropertyGroup>
<!-- Inject the publication of "secondary" sites into the Windows Azure build/project packaging process. -->
<CoreBuildDependsOn>
CleanSecondarySites;
PublishSecondarySites;
$(CoreBuildDependsOn)
</CoreBuildDependsOn>
<!-- This is the directory within the web application project directory to which the project will be "published" for later packaging by the Azure project. -->
<SecondarySitePublishDir>azure.publish\</SecondarySitePublishDir>
</PropertyGroup>
<!-- These SecondarySite items represent the collection of sites (other than the web application associated with the role) that need special packaging. -->
<ItemGroup>
<SecondarySite Include="..\WebApplication1\WebApplication1.csproj" />
<SecondarySite Include="..\WebApplication2\WebApplication2.csproj" />
</ItemGroup>
<Target Name="CleanSecondarySites">
<RemoveDir Directories="%(SecondarySite.RootDir)%(Directory)$(SecondarySitePublishDir)" />
</Target>
<Target Name="PublishSecondarySites" Condition="'$(PackageForComputeEmulator)' == 'true'
Or '$(IsExecutingPublishTarget)' == 'true' ">
<!--
Execute the Build (and more importantly the _WPPCopyWebApplication) target to "publish" each secondary web application project.
Note the setting of the WebProjectOutputDir property; this is where the project will be published to be later picked up by CSPack.
-->
<MSBuild Projects="%(SecondarySite.Identity)" Targets="Build;_WPPCopyWebApplication" Properties="Configuration=$(Configuration);Platform=$(Platform);WebProjectOutputDir=$(SecondarySitePublishDir)" />
The build task will run in Visual Studio when you build the project. You need to make sure that the minified files are also being deployed to Azure.
I'm guessing that perhaps because the item is being generated at build-time that it's not part of the project itself, and is this ignored by the deployment step.
Please check that the deployment system being used will include all the script files and not just the ones that are in the project itself.

Resources