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).
Related
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
Problem: So, my issue is that I have 3 .dll files I want to include in my software. However, whenever I transfer the .exe to another computer, it looks for my hard coded absolute path in my computer. I want the dlls to be included or embedded such that I can distribute it to others.
Setup:
I have done so by going to the solution explorer and doing Add->Exisiting Item, and add the three dlls into the solution explorer.
Then I went to each .dll's properties and changed them so that they are considered embedded resources. Like so:
Then I went to the references tab of the project property, and added a reference to the three dlls in my code. I originally had them in my /bin/ folder of my project, but I still had this problem. so I added them here in the same folder as my project.
Great, so I compile, copy to another computer, and get an exception (I threw it to a message box for ease) saying it can't find the dll and/or its dependencies. I even put a copy of the dll in the same .exe folder on the separate computer, but the same problem.
What I've Tried: So I tried messing around with the project file. But it looked ok to me. Here's a snippet:
<ItemGroup>
<Reference Include="PcapDotNet.Base, Version=0.10.0.20588, Culture=neutral, PublicKeyToken=4b6f3e583145a652, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\PcapDotNet.Base.dll</HintPath>
</Reference>
<Reference Include="PcapDotNet.Core, Version=0.10.0.20632, Culture=neutral, PublicKeyToken=4b6f3e583145a652, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\PcapDotNet.Core.dll</HintPath>
</Reference>
<Reference Include="PcapDotNet.Packets, Version=0.10.0.20603, Culture=neutral, PublicKeyToken=4b6f3e583145a652, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\PcapDotNet.Packets.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
and later ...
<ItemGroup>
<EmbeddedResource Include="PcapDotNet.Base.dll" />
<EmbeddedResource Include="PcapDotNet.Core.dll" />
<EmbeddedResource Include="PcapDotNet.Packets.dll" />
</ItemGroup>
Question: So, why is it saying it can't find the dll? Where could it still be looking for it in the wrong place?
Thanks everyone!
Thanks for the help guys! I found the solution was a problem with Pcap dot net (pcap.net). The issue was that the supporting computer didn't have the Microsoft Redistributable C++ package. It says that is needed on their website. I thought that was for development only, but turns out it is needed for running as well. I might try to include those dll's in the embedded resources as well to clean it up for the user.
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.
I'm new to MSBuild and was wondering how could you copy all files in your lib directory to your build directory? if you could point to some online resource that would be fine.
You can use a copy task.
Refer to this URL(definition and example): http://msdn.microsoft.com/en-us/library/3e54c37h.aspx
visual studio uses ItemGroup/Reference and ItemGroup/Content for this
<ItemGroup>
<Reference Include="nunit.framework,...">
<HintPath>..\..\..\lib\nunit.framework.dll</HintPath>
</Reference>
<Content Include="TestData\nwind.mdb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
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.