Umbraco auto generate web.config if missing - msbuild

We have a Umbraco website that references Umbraco.Web.UI,
<Reference Include="Umbraco.Web.UI, Version=8.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UmbracoCms.Web.8.12.2\lib\net472\Umbraco.Web.UI.dll</HintPath>
</Reference>
If we see the source code of Umbraco.Web.UI, then we see there is copy action that generates web.config from web.Template.config.
https://github.com/umbraco/Umbraco-CMS/blob/34e80d86e8c0b754f6b7a02e307f53cb32806bbe/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj#L369
But as far as I know if I just reference Umbraco.Web.UI.dll then these MSBuild actions in Umbraco.Web.UI.dll will not run.
My question is that how come web.config is generated if I build the project and web.config is missing.
The problem is that we have removed web.config from the repository and we wanna to understand how this web.config is generated so that we can modify it when we deploy.

So my csproj is using,
<Import Project="..\packages\UmbracoCms.8.12.2\build\UmbracoCms.targets"
and UmbracoCms.targets have the below action

Related

The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime" from TeamCity

I'm getting the above error from our TeamCity build.
I have tried adding the following lines to the web.config.
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
I have also installed the latest Windows SDK for .NET4.5.2.
Neither of these have resolved the error.
Any ideas?
Finally found a solution to this problem. I added a reference to the System.Runtime.dll assembly to my project. I added a reference to the following file to my project (substitute your own version of .NET in the path as necessary). You could always copy the file to your project folder and link it from there as an alternative.
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades
This worked for me and hopefully will work for someone else.

Msbuild add reference path

I am using TeamCity to build my solutions remotely and one of my projects has a reference path which is different from the build server. Is there anyway that I can change or add the reference hintpath in the command line of the Visual Studio Runner before the project builds so that the dependency is resolved?
<ItemGroup>
<Reference Include="FeedOSAPI_vc10, Version=2.5.2.1, Culture=neutral>
<SpecificVersion>False</SpecificVersion>
<HintPath>path</HintPath>
</Reference>
<Reference Include="FeedOS_Managed_vc10, Version=0.0.0.0, Culture=neutral>
<SpecificVersion>False</SpecificVersion>
<HintPath>"path</HintPath>
</Reference>
</ItemGroup>
One way you can accomplish this is to use environment variables, both on Build Servers and developer workstations. You can create a binary repository, it can be VCS repository or simlpe file server, and after that you can have one source code for projects which will be able to build anywhere, where the prerequisite conditions are met.
Create environment variable, for example BinRepo, both on Build Server and on dev machine.
Use it in the project like this:
<Reference Include="FeedOSAPI_vc10, Version=2.5.2.1, Culture=neutral>
<SpecificVersion>False</SpecificVersion>
<HintPath>$(BinRepo)FeedOS\FeedOSAPI_vc10.dll</HintPath>
</Reference>
<Reference Include="FeedOS_Managed_vc10, Version=0.0.0.0, Culture=neutral>
<SpecificVersion>False</SpecificVersion>
<HintPath>$(BinRepo)FeedOS\FeedOS_Managed_vc10.dll</HintPath>
</Reference>
Thus you have single code base, and you do not need to specify it elsewhere in the project or from the command line (but you have the ability to do so).

Visual Studio Add Reference - UAC path

I have read the following webpage: http://msdn.microsoft.com/en-us/library/ee817675.aspx and I am interested in the section: 'Use File References Only Where Necessary'
The section seems to suggest that you can add a reference to a DLL on a server. I have version 11 of Oracle.DataAccess on my development PC and version 10 on the live server. It is a pain to deploy the application.
The web page says that a project file should contain a 'References' node, but when I right click on a project file and open with TextPad, there is only an ItemGroup (http://msdn.microsoft.com/en-us/library/646dk05y%28v=vs.90%29.aspx) node. Therefore I have two questions:
1) Where can I find the References node as stated on the webpage?
2) Is it possible to reference an assembly using the UAC path instead of a local path?
Referenced projects is placed in ItemGroup starting from MSBuild 2.0 first link is outdated it from Visual Studion .NET times .NET 1.0/1.1.
<ItemGroup>
<!-- ... -->
<Reference Include="System" />
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<!-- ... -->
</ItemGroup>
For the second question I think yes if you mean UNC path.

MSBuild: building website using AspNetCompiler - adding references?

I'm attempting to build a ASP.NET website using MSBuild - specifically the AspNetCompiler tag. I know that, for my project, I need to add some references. Within Visual Studio I have several references, one is a project reference and the others are some DLLS (AjaxControlToolkit etc). I'm happy not referencing the project and referencing the DLL instead - however I just can't work out how to add a reference. I've looked up and down and this is what I've found so far:
<Target Name = "PrecompileWeb">
<AspNetCompiler
VirtualPath = "DeployTemp"
PhysicalPath = "D:\AutoBuild\CruiseControl\Projects\Websites\MyCompany\2.0.0\WorkingDirectory\VSS"
TargetPath = "D:\AutoBuild\CruiseControl\Projects\Websites\MyCompany\2.0.0\PreCompiled"
Force = "true"
Debug = "true"
Updateable = "true"/>
</Target>
Also - I've picked up this bit of code from around the web somewhere, which I thought might help:
<ItemGroup>
<Reference Include="My.Web.DataEngine, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\AutoBuild\CruiseControl\Projects\Components\My.Web.DataEngine\bin\Debug\My.Web.DataEngine.dll</HintPath>
</Reference>
</ItemGroup>
What I want to do is add a attribute to the AspNetCompiler tag, something like:
References="#(Reference)"
but MSBuild isn't very happy about this.
I've been a bit stuck in not being able to find decent references on doing this anywhere: so I'd really apprechiate some pointers or reference material etc. (or just the answer!)
Thanks for you help.
-tom
The aspnet_compiler tool doesn't have a reference property.
Have you looked at using Web Deployment Projects (2005 version)?
You can add references to assemblies used during the compilation of an ASP.NET application by adding to the <assemblies> element, under <compilation> if your web.config. For example:
<compilation targetFramework="4.6.2" debug="true">
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
Read more here: https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/bfyb45k1(v=vs.100)

.NET Different References List for Debug / Release

In my debug build I have a reference to a DLL that is only required in the Debug configuration (the reference is for CodeSite, a logging tool).
Is it possible to exclude this reference in the Release build (my logging class only uses this reference when built in the Debug configuration).
Using VB.NET and VS2008.
Yes this is possible but it will require you to manually edit the .vbproj file. Once you have the file open you'll an XML reference tag for the DLL's you've referenced and it will look like the following
<Reference Include="SomeDllName" />
You need to add a condition property which species it should only be done during debug time
<Reference Include="SomeDllName" Condition="'$(Configuration)'=='Debug'" />
It's possible to do this, but you'll need to mess with the project file manually.
We do this in MiscUtil so we can have a .NET 2.0 build and a .NET 3.5 build. For instance:
<ItemGroup Condition=" '$(Configuration)' != 'Release 2.0' ">
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
<Aliases>global</Aliases>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
That should be enough to get you started :) Basically take the current reference out of where it is in your normal project file, and put it in its own ItemGroup with an appropriate condition.