MSBuild failing due to sgen.exe error

704 views Asked by At

I don't know where to start. My build fails in Release mode. Error message is:

SGEN : error : Method 'ExecuteAuthorizationFilterAsync' in type 'Api.Attributes.ModuleAuthorizeAttribute' from assembly 'Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

It obviously does have an implementation, it builds until the sgen task. (And in Debug mode it totally builds, since there is no sgen.)

While I could change build options like here I'd rather get to the source of the problem and not disable optimization.

Also tried to make a small app to reproduce the problem but failed, and uploading this app is not an option. It's huge and not mine to share.

2

There are 2 answers

0
Amit On

I added the following in csproj for release mode as a work around.

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
                :
    <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
                :
</PropertyGroup>

Changing the reference tag to something like <Reference Include="dll name"/> did not work for me.

0
MotKohn On

I was able to fix it. But it doesn't make sense to me.

Changing the following lin in the .csproj helped.

<Reference Include="System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
  <HintPath>..\packages\System.Net.Http.4.3.3\lib\net46\System.Net.Http.dll</HintPath>
</Reference>

To

<Reference Include="System.Net.Http"/>

worked. Obviously not satisfied. Hopefully someone will come up with a solution/explanation, but posted in case it helps someone else.