Reputation: 1127
when we are trying to generate fakes wit dotnet core 5.0 version with config as
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="Renci.SshNet"/>
</Fakes>
we are getting the below error
obj\Debug\net5.0-windows10.0.19041.0\Fakes\rsn\o\net5.0-windows10.0.19041.0\f.AssemblyInfo.cs' could not be found. [projectlocation\obj\Debug\net5.0-windows10.0.19041.0\Fakes\rsn\f.csproj]
can you please suggest what we are missing?
Upvotes: 1
Views: 541
Reputation: 102
AssemblyInfo.cs is useful, but it's not necessary.
In .NetCore you can manage assembly info from the csproj file instead of AssemblyInfo. The file will be autogenerated in obj folder for you. All you need to do is to set them in the csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>myAppName</AssemblyName>
</PropertyGroup>
</Project>
The compiler will complain about duplicate properties if there is an AssemblyInfo present in your project with any properties set. In this case you should set GenerateAssemblyInfo
to false (so that it doesn't auto-generate an x.AssemblyInfo.cs into obj folder):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyName>myAppName</AssemblyName>
</PropertyGroup>
</Project>
You can choose to handle the assembly information manually but setting auto-generate attributes to false (such as GenerateAssemblyInfo
or GenerateAssemblyTitleAttribute
etc.) which means you can set the assembly information in both AssemblyInfo and csproj. This comes in handy when you want to share a common set of information between different projects, while being able to change some info in each of them. (You can't set a property twice though, but still this is a useful feature).
To create a new assembly file:
Upvotes: 0