Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet-clean and project.assets.json in 2.0 #8740

Closed
sstevenkang opened this issue Sep 20, 2017 · 1 comment
Closed

dotnet-clean and project.assets.json in 2.0 #8740

sstevenkang opened this issue Sep 20, 2017 · 1 comment

Comments

@sstevenkang
Copy link

I would like to know why "dotnet clean" depends on project.assets.json file. This new behavior in 2.0 is something we can work around, but I would like to understand why this change in behavior was introduced and what is the project structure expectation of dotnet cli.

Is multiple .csproj files in a single directory not supported/encouraged?

Steps to reproduce

In our project, we have this folder structure for historical reasons:

/obj
/bin
/src
Project.Net35.csproj
Project.Net45.csproj

Pre 2.0, we used to do following commands in sequence:

# build net35
dotnet clean Project.Net35.csproj
dotnet restore Project.Net35.csproj
dotnet build Project.Net35.csproj

# build net45
dotnet clean Project.Net45.csproj
dotnet restore Project.Net45.csproj
dotnet build Project.Net45.csproj

Both .csproj are in the new vs2017 csproj format that starts with <Project Sdk="Microsoft.NET.Sdk">

Expected behavior

The above folder structure worked pre-2.0 because "dotnet clean" command did not take a dependency/make a reference to project.assets.json file and succeeded.

Actual behavior

With 2.0, we see the following error message during dotnet clean:

C:\Program Files\dotnet\sdk\2.0.0\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file 'd:\workspace\Project\obj\project.assets.json' doesn't have a target for '.NETFramework,Version=v4.5'. Ensure that restore has run and that
you have included 'net45' in the TargetFrameworks for your project. [d:\workspace\Project\Project.Net45.csproj] [
d:\workspace\build.proj]

I think we can workaround this by specifying different obj directory per project or doing dotnet restore -f before dotnet clean. Ideally, we would build for both frameworks in a single .csproj, but it's not something we can invest time in currently.

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
@mishra14
Copy link
Contributor

@sstevenkang you are facing this problem because you have 2 different csproj files in the same folder. You can workaround this by adding a --Force to the restore calls which will result in rewriting of the assets file each time.

Related issue: NuGet/Home#6114

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants