2

How to build Autofac from sources? I found only one deprecated wiki page.

I've tried to launch go.cmd (.NET Framework 4.0), but it failed with errors:

    C:\Autofac\Autofac.csproj" (default target) (4) ->
    (CoreCompile target) ->
    Builder\MetadataConfiguration.cs(28,14): error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
    [C:\Autofac\Core\Source\Autofac\Autofac.csproj] Features\LazyDependencies\LazyWithMetadataRegistrationSource.cs(28,14): error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) 

What I am doing wrong?

asa
  • 1,827
  • 2
  • 15
  • 18

2 Answers2

3

Autofac 3.0 has been updated so the core Autofac.dll is a Portable Class Library that targets multiple platforms. Portable Class Libraries don't have references to System assemblies so the missing System.Core reference is correct - it shouldn't be there. You should be able to use the Portable Class Library with .NET 4... or with Windows Store or Windows Phone 8 apps. I strongly recommend not modifying the references for the .csproj. You'll break that compatibility and inadvertently change the target profiles.

The wiki page on building from source has been deprecated because the instructions for building are in a readme right in the root of the source code. (That's mentioned on that deprecated wiki page - first line.) It explains all the prerequisite tools and commands required. If you follow the information in there, you should not have to modify anything to get the source to build.

If you aren't modifying the sources, I'm not sure why you'd need to rebuild the source to target .NET 4 specifically. It should just work. If you see something that isn't working, please file an issue about it on the Autofac site.

If you are modifying the source, the readme in there should get you building without messing with the project references.

Travis Illig
  • 23,195
  • 2
  • 62
  • 85
  • Thank you Travis. My reason is following: when I am using Autofac.dll from the Nuget package (.net40 folder) it has a reference to mscorlib ver. 2, but expect to see ver. 4 instead. dotPeak confirms it. Why is that? – asa Dec 25 '12 at 15:59
  • That's part of the Portable Class Library mechanism. Ignore it unless it's causing problems. You should be able to use what's shipped. If it's not working as shipped, truly, please file an issue because we'll want to fix it before the final 3.0 ships. (Do file the issue rather than just leaving it in comments here if there is a problem. Issues get handled; comments here may get overlooked.) – Travis Illig Dec 25 '12 at 23:22
  • If you're unfamiliar with Portable Class Libraries (new in VS 2012) there's plenty of doc on MSDN. – Travis Illig Dec 25 '12 at 23:23
  • Using Autofac 3 beta 2 from package does not really cause any problems. But I have warnings during compilation and ReSharper (7.1.1) could not recognize Module block and shows errors about using mscorlib, System both of ver. 2 and ver. 4. But it might be an issue of PCL. – asa Dec 26 '12 at 09:12
  • That sounds like PCL. I'd ask a different question about that and tweet it to @davkean, one of the PCL devs. – Travis Illig Dec 26 '12 at 14:36
1

It looks like the Autofac.csproj does not include a reference to system.core. See also this question and this bugreport. So can you try to add this to the Autofac.csproj file:

<ItemGroup>
    <Reference Include="System.Core" />
</ItemGroup>

Possibly you also have to add other references, such as System.

Community
  • 1
  • 1
wimh
  • 15,072
  • 6
  • 47
  • 98
  • Thanks! It works. I just wanted to rebuild Autofac for .NET 4. I have mscorlib 2 warning when using it from the NuGet package https://nuget.org/packages/Autofac/3.0.0-beta2. – asa Dec 25 '12 at 07:36