Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Knudsen 3 posts 73 karma points
    Feb 11, 2021 @ 08:51
    Martin Knudsen
    0

    Duplicate AssemblyVersion Attribute

    I have this strange error that no amount of Googling on SO etc or here seems to solve for me.

    Everything worked fine and then suddenly I get a lot compile errors - as you can see the screenshot below.

    It says there is a "Duplicate Assembly Version atttribute" in the AssemblyInfo.cs file, but I have checked and there is not.

    This leads to a host of other errors as you can see in the models.generated.cs file.

    It's running the newest version of Umbraco and with the standard purelive model generation (I have not changed that). enter image description here

  • AddWeb Solution Pvt. Ltd 109 posts 360 karma points
    Feb 11, 2021 @ 10:50
    AddWeb Solution Pvt. Ltd
    0

    Hello Martin,

    I think that your build process provides assembly information separately to providing versioning. And that causes a duplication as your project also has that info in the AssemblyInfo.cs file. So remove the file and I think it should work Another solution to keep using the AssemblyInfo.cs file is to turn off automatic assembly info generation like this:

    <Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    </PropertyGroup>
    </Project>
    
  • Martin Knudsen 3 posts 73 karma points
    Feb 11, 2021 @ 13:48
    Martin Knudsen
    0

    Thanks for the suggestions. But none of this works.

    I am thinking it might have something to do with whether you are using PureLive or AppData : https://our.umbraco.com/Documentation/Reference/Templating/Modelsbuilder/Builder-Modes

    When I exclude the AppData/Models folder from the project and using PureLive the error disappear from the actual build - although I still get some errors with the IntelliSense, which seems to not pick up all the models. But then I can at least compile and run the project - the only left is the errors with IntelliSense.

  • Thomas Kassos 54 posts 265 karma points
    Feb 11, 2021 @ 14:26
    Thomas Kassos
    0

    Hi Martin,

    I had similar errors when I was playing with the generated Models. Double check your bin folder for any unwanted dll form previously generated models. In my case that was the issue.

    Also I have found it easier to work with the models builder api. For this one to try you will need to install this package https://www.nuget.org/packages/Umbraco.ModelsBuilder.Api/

    Add this settings to web config.

    <add key="Umbraco.ModelsBuilder.Enable" value="true" />
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Nothing" />
    <add key="Umbraco.ModelsBuilder.EnableApi" value="true" />  
    

    Install this visual studio plugin https://marketplace.visualstudio.com/items?itemName=ZpqrtBnk.UmbracoModelsBuilderCustomTool

    after install the vs plugin you have to go to visual studio tools -> options -> Umbraco and add the credentials of the umbraco back office (site url is your local host url)

    enter image description here

    then you just have to create a .mb file and generate the models, you will find more info about that here. (The site needs to be running when you want to generate models. )

    https://www.zpqrtbnk.net/posts/models-builder-extension/

    And again make sure you have deleted any previously models builder generated dlls or files

    Thanks, Thomas

  • guntur hakim 2 posts 72 karma points
    Feb 19, 2021 @ 06:48
    guntur hakim
    0

    Hi All. I have same error after reading little bit, so I do follow advice from Thomas and now works well at the site best regards thanks

  • Martin Knudsen 3 posts 73 karma points
    Feb 19, 2021 @ 08:34
    Martin Knudsen
    0

    Ok, Guntur.

    So you just deleted everything from the bin folder and it worked after that?

Please Sign in or register to post replies

Write your reply to:

Draft