obj and bin sub-foldersmsbuild <project-name>.csprojobj\Debug\netstandard1.3\<project-name>.AssemblyInfo.cs://------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("xxx")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("Package Description")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("xxx")]
[assembly: System.Reflection.AssemblyTitleAttribute("xxx")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.
The problem does not appear when the folder
obj\Debug\netstandard1.3exists.
@jeffkl any idea why this is happening?
Did you restore after deleting the obj folder? Deleting that folder is pretty much undoing restore as well so there won't be any compilation references that define all the attributes..
No I didn't restore, I know I should, but don't you think it's odd that msbuild creates a file containing non-compilable attributes. And don't you think that the msbuild script code that generates the file should be deleted or at least modified...
And don't you think that the msbuild script code that generates the file should be deleted or at least modified...
I'm not sure this would make the situation any better.. If the obj/project.assets.json file is missing, not even System.Object is valid and no code will be able to compile. Even if you turn off assembly info generation via <GenerateAssemblyInfo>false</GenerateAssemblyInfo>, none of the other code in the library would be able to compile successfully.
I believe that it would be better to invest more into a meaningful error message saying that the project has not been restored which is tracked by https://github.com/Microsoft/msbuild/issues/1139.
(Note: i'm not affiliated with MS).
Thank you very much for your explanations. You are right, I tried to turn off assembly info generation and I get an error saying : project.assets.json not found.
Still good to know that assembly info generation code should be disabled when building .NET standard / Core projects...
Just to be clear, the ability to disable generation of those attributes is helpful in cases where you already have an AssemblyInfo.cs file in your project (and maybe have tooling for it - e.g. GitFlow) or don't want one of the generated attributes to be generated (each one can be controlled via properties like GenerateAssemblyCompanyAttribute).
Every attribute is valid on and can be used for .net standard and .net core projects.
馃憤 Thank you again... I should have looked at the error message of the compiler saying:
error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute
Hope the documentation will explain this type of things...
If you keep AssemplyAttributes in AssemblyInfo.cs, you can turn off auto-generated assembly attributes.
in csproj:
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
Now, no file is generated and sucess compilation
Sounds like this had a better error than it seemed at first glance and was resolved by restoring.
Most helpful comment
Just to be clear, the ability to disable generation of those attributes is helpful in cases where you already have an AssemblyInfo.cs file in your project (and maybe have tooling for it - e.g. GitFlow) or don't want one of the generated attributes to be generated (each one can be controlled via properties like
GenerateAssemblyCompanyAttribute).Every attribute is valid on and can be used for .net standard and .net core projects.