Home Dashboard Directory Help
Search

Visual Studio 2012 - Add Fakes Assembly does not add all needed references by T.M. Douma


Status: 

Closed
 as Fixed Help for as Fixed


4
0
Sign in
to vote
Type: Bug
ID: 782031
Opened: 3/25/2013 7:07:49 AM
Access Restriction: Public
2
Workaround(s)
view
2
User(s) can reproduce this bug

Description


In one of our projects Visual Studio 2012's option "Add Fakes Assembly" does not add all needed references to the generated f.csproj file.

This is causing an error.

Error    1    The type '<typename>' is defined in an assembly that is not referenced. You must add a reference to assembly '<ReferencedAssembly>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6740fce60587153a'. [C:\Projects\TFS\<TestProject>\obj\Release\Fakes\dfzab\f.csproj]    C:\Projects\TFS\<TestProject>\f.cs    31599    26    <ProjectName>


The Assembly I'm generating the fake for does have a reference to correct assembly.

After examing the f.csproj file i noticed the reference to the assembly was not there.

I managed to reproduce this issue in a Demo Project. I added the project to this feedbackitem.
Details
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:29 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by Microsoft on 5/15/2013 at 3:37 PM
T.M. Douma,

I just fixed this bug and I also tried your attached project. The generated F.CSPROJ now compiles fine. It should be available in the later release.

Thanks!
Patrick Tseng
Posted by Microsoft on 4/25/2013 at 9:11 AM
T.M. Douma,

Thanks for reporting this issue to us. The product team is currently investigating the proper fix and timing to address this issue.

Thanks,
Joshua Weber
Posted by Microsoft on 3/26/2013 at 1:31 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 3/25/2013 at 9:32 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

Please submit this information to us within 4 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 3/25/2013 at 7:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Oleg V. Sych on 9/6/2013 at 8:45 AM
Disregard instructions in the comments inside of the project template. The Fakes code generator automatically updates project guid, root namespace and assembly name.
Posted by Oleg V. Sych on 6/26/2013 at 10:03 AM
To work around this problem, you can modify the .FAKES file, add a Compilation element and specify a project template that contains the missing reference.

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/" Verbosity="Verbose" Diagnostic="true">
<Assembly Name="Fakes.Reference.Issue.Business"/>
<Compilation ProjectTemplate="FakesProjectTemplate.csproj"/>
</Fakes>

The project template file (FakesProjectTemplate.csproj) should be located in the same folder as the test project containing the .FAKES file (Fakes.Reference.Issue.Business.Test). Here is the project template that adds a reference to the ReferencedAssembly.Common required in this instance. This is a regular C# project file with a required Reference element added at the end.

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.21022</ProductVersion>
    <ProjectGuid />
    <!-- update GUID here -->
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace />
    <!-- update root namespace -->
    <AssemblyName />
    <!-- update assembly name -->
    <CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
    <CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
    <OutputPath>bin\$(Configuration)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <DefineConstants>DEBUG;TRACE;$(CommonDefineConstants)</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
    <NoWarn>1587;1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <DefineConstants>TRACE;$(CommonDefineConstants)</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
    <NoWarn>1587;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
    <Reference Include="ReferencedAssembly.Common">
     <HintPath>..\..\..\..\..\ReferencedAssembly.Common\bin\debug\ReferencedAssembly.Common.dll</HintPath>
    </Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Attached is the original repro project, modified to implement the workaround.
File Name Submitted By Submitted On File Size  
Fakes.ReferenceIssue.zip 3/26/2013 248 KB
Fakes.ReferenceIssue.Workaround.zip 6/26/2013 20 KB