Nikhil Kumar K
Nikhil Kumar K

Reputation: 1127

dotnet core 5.0 version not generating fakes and throwing assembly.cs not found

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

Answers (1)

DraggonDragger
DraggonDragger

Reputation: 102

Solution 1:

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).

Solution 2:

  1. Right click on project (not solution)
  2. Unload project
  3. Re-load project
  4. Rebuild solution

Solution 3:

To create a new assembly file:

  1. Right-click project properties (not solution).
  2. Choose Application tab.
  3. Click Assembly Information button. Fields will probably be all empty.
  4. Add stuff.
  5. Click OK and exit properties.
  6. Rebuild.

Upvotes: 0

Related Questions