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

BaseIntermediateOutputPath is not supported with /restore #3695

Closed
CodeTroopers opened this issue Sep 4, 2018 · 4 comments
Closed

BaseIntermediateOutputPath is not supported with /restore #3695

CodeTroopers opened this issue Sep 4, 2018 · 4 comments
Labels

Comments

@CodeTroopers
Copy link

Steps to reproduce

With a solution with vbproj and csproj containing PackageReference and ProjectReference for several projects :

  <ItemGroup>
    <PackageReference Include="EPPlus">
      <Version>4.1.0</Version>
    </PackageReference>
    <PackageReference Include="Newtonsoft.Json">
      <Version>11.0.2</Version>
    </PackageReference>
  </ItemGroup>

Run MSBuild with the command line :

msbuild /restore /toolsversion:15.0 /property:BaseIntermediateOutputPath=c:\temp;VisualStudioVersion=15.0 mySolution.sln

Environment data

msbuild /version output: 15.7.179.6572

Expected behavior

The build would must be in success

Actual behavior

The build fails with several errors due to missing references :

error BC30002: Type 'Newtonsoft.Json.JsonIgnore' is not defined.
error BC40056: Namespace or type specified in the Imports 'OfficeOpenXml' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

If i remove the property BaseIntermediateOutputPath from the command line then the build is in success

msbuild /restore /toolsversion:15.0 /property:VisualStudioVersion=15.0 mySolution.sln

Extracted from the log file

....
Using "GetRestorePackageReferencesTask" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll".
Task "GetRestorePackageReferencesTask"
(in) ProjectUniqueName 'C:\Builds\Project1.vbproj'
(in) TargetFrameworks ''
(in) PackageReferences 'EPPlus;Newtonsoft.Json'
Done executing task "GetRestorePackageReferencesTask".
...
...
...
Using "GetRestorePackageReferencesTask" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll".
Task "GetRestorePackageReferencesTask"
(in) ProjectUniqueName 'C:\Builds\Project2.vbproj'
(in) TargetFrameworks ''
(in) PackageReferences 'EPPlus'
Done executing task "GetRestorePackageReferencesTask".
...
...
...
Using "GetRestorePackageReferencesTask" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll".
Task "GetRestorePackageReferencesTask"
(in) ProjectUniqueName 'C:\Builds\Project3.csproj'
(in) TargetFrameworks ''
(in) PackageReferences 'Newtonsoft.Json'
Done executing task "GetRestorePackageReferencesTask".
...
...
...
Using "GetRestorePackageReferencesTask" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll".
Task "GetRestorePackageReferencesTask"
(in) ProjectUniqueName 'C:\Builds\Project4.csproj'
(in) TargetFrameworks ''
(in) PackageReferences 'BouncyCastle.Crypto.dll'
Done executing task "GetRestorePackageReferencesTask".
...
...
...
Using "RestoreTask" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll".
Task "RestoreTask"
(in) RestoreGraphItems Count '463'
(in) RestoreDisableParallel 'False'
(in) RestoreNoCache 'False'
(in) RestoreIgnoreFailedSources 'False'
(in) RestoreRecursive 'True'
(in) RestoreForce 'False'
(in) HideWarningsAndErrors 'False'
Running restore with 2 concurrent jobs.
Reading project file C:\Builds\Project4.csproj.
Restoring packages for C:\Builds\Project4.csproj...
Restoring packages for .NETFramework,Version=v4.7.1...
Resolving conflicts for .NETFramework,Version=v4.7.1...
Scanning packages for runtime.json files...
Restoring packages for .NETFramework,Version=v4.7.1/win...
Resolving conflicts for .NETFramework,Version=v4.7.1/win...
Restoring packages for .NETFramework,Version=v4.7.1/win-x64...
Resolving conflicts for .NETFramework,Version=v4.7.1/win-x64...
Restoring packages for .NETFramework,Version=v4.7.1/win-x86...
Resolving conflicts for .NETFramework,Version=v4.7.1/win-x86...
Checking compatibility of packages on .NETFramework,Version=v4.7.1.
Checking compatibility for Refresh.Common.Utils 1.0.0.0 with .NETFramework,Version=v4.7.1.
Checking compatibility for BouncyCastle.Crypto.dll 1.8.1 with .NETFramework,Version=v4.7.1.
All packages and projects are compatible with .NETFramework,Version=v4.7.1.
Checking compatibility of packages on .NETFramework,Version=v4.7.1 (win).
Checking compatibility for Refresh.Common.Utils 1.0.0.0 with .NETFramework,Version=v4.7.1 (win).
Checking compatibility for BouncyCastle.Crypto.dll 1.8.1 with .NETFramework,Version=v4.7.1 (win).
All packages and projects are compatible with .NETFramework,Version=v4.7.1 (win).
Checking compatibility of packages on .NETFramework,Version=v4.7.1 (win-x64).
Checking compatibility for Refresh.Common.Utils 1.0.0.0 with .NETFramework,Version=v4.7.1 (win-x64).
Checking compatibility for BouncyCastle.Crypto.dll 1.8.1 with .NETFramework,Version=v4.7.1 (win-x64).
All packages and projects are compatible with .NETFramework,Version=v4.7.1 (win-x64).
Checking compatibility of packages on .NETFramework,Version=v4.7.1 (win-x86).
Checking compatibility for Project4 1.0.0.0 with .NETFramework,Version=v4.7.1 (win-x86).
Checking compatibility for BouncyCastle.Crypto.dll 1.8.1 with .NETFramework,Version=v4.7.1 (win-x86).
All packages and projects are compatible with .NETFramework,Version=v4.7.1 (win-x86).
Committing restore...
Generating MSBuild file c:\temp\Project4.csproj.nuget.g.props.
Generating MSBuild file c:\temp\Project4.csproj.nuget.g.targets.
Writing lock file to disk. Path: c:\temp\project.assets.json
Writing cache file to disk. Path: c:\temp\Project4.csproj.nuget.cache
Restore completed in 1,13 sec for C:\Builds\Project4.csproj.

NuGet Config files used:
C:\Users\TFSBuild\AppData\Roaming\NuGet\NuGet.Config

Feeds used:
https://api.nuget.org/v3/index.json
Done executing task "RestoreTask".
Done building target "Restore" in project "mySolution.sln".
Done Building Project "C:\Builds\mySolution.sln" (Restore target(s)).
Project "C:\Builds\mySolution.sln" on node 1 (default targets).
Building with tools version "15.0".
...
...
...

@jeffkl
Copy link
Contributor

jeffkl commented Sep 4, 2018

This is technically by design as BaseIntermediateOutputPath has become a property that you cannot set as a global property. When you set it via the command-line argument /Property it is used by all projects that are built. NuGet writes out an assets file, project.assets.json to the BaseIntermediateOutputPath location. If the same value is used by all projects, then the file is written multiple times with only the last one winning. This will cause build breaks since most likely there will be a missing dependency.

Your value for BaseIntermediateOutputPath must be unique per project. This means it can only really be set in an MSBuild import/project. You can set it in Directory.Build.props with something like:

  <PropertyGroup>
    <BaseIntermediateOutputPath>$(Root)\obj\$(MSBuildProjectFile)</BaseIntermediateOutputPath>
  </PropertyGroup>

@CodeTroopers
Copy link
Author

CodeTroopers commented Sep 5, 2018

If the same value is used by all projects, then the file is written multiple times with only the last one winning.

Does NuGet could write an incremential file instead of to write a new file for each project?

@dasMulli
Copy link
Contributor

dasMulli commented Sep 5, 2018

It would be interesting if the assets file would change from project.assets.json to $(MSBuildProjectName).assets.json.
It would solve a lot of projects.
Maybe this can be considered for 16.0 / NuGet 5? @jeffkl could you take that to the involved teams for discussion?

@jeffkl
Copy link
Contributor

jeffkl commented Sep 5, 2018

There's an open issue for having a project-specific name for the assets file here: NuGet/Home#4463

@CodeTroopers I'd like to close this issue if you agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants