MSBuild: building website using AspNetCompiler - adding references? - msbuild

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)

Related

Umbraco auto generate web.config if missing

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

Could not find System.Object VB.NET

Error : Fody: Could not find 'System.Object'. WindowsApp1
hi, something called Fody, it embed dlls assembly into project.
problem is it work only with C# |and i need use it as VB, i cant reduce Netframwork less than 4.6 cause dll's required high netframwork.
error only occurs when running Fody on a VB assembly using the full .Net Framework
so they say it can be solve By
try adding explicit references to your VB project
<Reference Include="mscorlib" />
<Reference Include="System" />
how can do it, because not automatically included in VB projects
Go to your Project file
edit vbproj
you can find <Reference Include="System" />
add before it <Reference Include="mscorlib" />

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.

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.

Sharepoint 2010 register control as safe through wsp

I created a "Hello World" Sharepoint 2010 solution using VS2010. It contains just a feature, and a webpart containing a label. I registered the webpart as a safe control in the "Properties" window of the webpart, in VS2010.
When I deploy my solution to my local server, everything works great! I can add the webpart to a page, and in the web.config file my control is added to the SafeControls list. When I install the same solution on a different server, I can see the webpart in the list of available webparts, but when I try to add it to the page, it tells me that it's not registered as safe. When I check the web.config file, there is no entry for my control. If I add one manually (the one from my dev server), things start to work.
Now, I wonder why the control is not registered when I install the wsp file. The manifest inside the wsp contains this line:
<Assemblies>
<Assembly Location="abc.TestWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="abc.TestWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e262c75e6f6e8440" Namespace="abc.TestWebPart.VisualWebPart1" TypeName="*" />
</SafeControls>
</Assembly>
Any ideas are very welcomed!
Check for typos and version differences.
Did you activate the feature for the web app?
Late answer I know.
I think you are missing ' Safe="TRUE" ' in your SafeControl Tag.
Correct code:
<Assemblies>
<Assembly Location="abc.TestWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl
Assembly="abc.TestWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e262c75e6f6e8440"
Namespace="abc.TestWebPart.VisualWebPart1"
TypeName="*"
Safe="TRUE"
/>
</SafeControls>
</Assembly>
</Assemblies>