-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Setting BaseIntermediateOutputPath breaks netstandard2.0 builds #2003
Comments
cc @dsplaisted can you take a look at this one? I remember you were looking at something similar already. |
Setting The problem is, when you build a project, its references are also built. In this case, when you build If we were to change it so that the Instead of trying to specify this on the command line, I'd suggest creating a <Project>
<PropertyGroup>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)_build\bin\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
</PropertyGroup>
</Project> See also #867 which proposes adding a property to specify a root path under which all project output (intermediate as well as final) would go. If we add such a property, then it should be possible to specify it from the command line. |
First, @livarcocc, @nguerrera... Thanks for your fast response! Very Great! @dsplaisted, ok. I understand and tried it. And it worked! But what about when I restore, build/publish with
This does not work. But it from the wording from the arguments it should. The question is, how can we tell the underlying compiler/linker the path to the 'pre-compiled' dotnetcore-lib.csproj obj dir? |
If you want to use a DLL directly instead of building the referenced project, then you can use a As for why |
@dsplaisted thanks for your support. |
@DoCode I'm not following. If you want to redirect the obj folder, then use a Directory.Build.props file like I suggested. The path you put in that file can be outside the project directory structure if you want it. You probably don't need to use the |
@dsplaisted thanks again! I am a little bit overcommited ;-)
The only problem is, that I can not dynamic parse the informations like cpu, architecture, target framework and so on, when I use the directory.build.props. |
@DoCode Yes, the target framework and runtime identifier aren't available at that point. By default they are appended to the path under the project-specific path. So if you set |
@dsplaisted ok. |
@DoCode No, these properties are set in evaluation, which is before any tasks are run. It's probably possible to get close to the layout you want, but it would be a lot trickier. You'd still set the You can use binary logs and MSBuild Structured Log Viewer to explore how the current output path calculations work, and help figure out how to override them with your own. Look for the |
Thanks a lot, Daniel (@dsplaisted)! |
@dsplaisted - sorry for the long delay. But other tasks have higher prio! I ended with this <?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<Import Project="../Directory.Build.props" Condition=" Exists('../Directory.Build.props') " />
<Import Project="../dir.props" Condition=" Exists('../dir.props') " />
<Import Project="SolutionItems/version/version.props" Condition=" Exists('SolutionItems/version/version.props') " />
<PropertyGroup Condition=" '$(ConfigPropsFileImported)' == 'true' ">
<!--
_build / bin /
-->
<BaseOutputPath>$(BinDir)/</BaseOutputPath>
<!--
_build / obj /
-->
<BaseIntermediateOutputPath>$(BaseOutputDir)/obj/$(MSBuildProjectName)/</BaseIntermediateOutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
</Project> And this <?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<Import Project="../Directory.Build.targets" Condition=" Exists('../Directory.Build.targets') " />
<Import Project="../dir.targets" Condition=" Exists('../dir.targets') " />
<PropertyGroup Condition=" '$(ConfigPropsFileImported)' == 'true' ">
<!--
_build / bin / win7.x64.debug / DotNetCore.ConsoleApp / netcoreapp2.1 /
_build / bin / $(_OS).$(_PlatformTarget).$(Configuration) / $(MSBuildProjectName) / $(_TargetFramework) /
-->
<_OS Condition=" '$(RuntimeIdentifier)' != '' ">$(RuntimeIdentifier.Split('-')[0])</_OS>
<_OS Condition=" '$(_OS)' == '' ">AnyOS</_OS>
<_PlatformTarget>$(PlatformTarget)</_PlatformTarget>
<_PlatformTarget Condition=" '$(_PlatformTarget)' == '' ">AnyCPU</_PlatformTarget>
<_TargetFramework>$(TargetFramework)</_TargetFramework>
<_TargetFramework Condition=" '$(_TargetFramework)' == '' AND '$(TargetFrameworkIdentifier)' == '.NETFramework' ">net$(_TargetFrameworkVersionWithoutV.Replace('.', ''))</_TargetFramework>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(_OS.ToLowerInvariant()).$(_PlatformTarget.ToLowerInvariant()).$(Configuration.ToLowerInvariant())/$(_TargetFramework.ToLowerInvariant())/</IntermediateOutputPath>
<IntermediateOutputPath>$(IntermediateOutputPath.TrimEnd('/').TrimEnd('\'))/</IntermediateOutputPath>
<OutputPath>$(BinDir)/$(_OS.ToLowerInvariant()).$(_PlatformTarget.ToLowerInvariant()).$(Configuration.ToLowerInvariant())/$(MSBuildProjectName)/$(_TargetFramework.ToLowerInvariant())/</OutputPath>
<OutputPath>$(OutputPath.TrimEnd('/').TrimEnd('\'))/</OutputPath>
<OutDir>$(OutputPath)</OutDir>
<BaseOutputPath>$(OutputPath)</BaseOutputPath>
<PackageOutputPath>$(OutputPath)</PackageOutputPath>
<TargetDir>$(OutputPath)</TargetDir>
<TargetPath>$(TargetDir)$(TargetFileName)</TargetPath>
<PublishDir>$(OutputPath)</PublishDir>
</PropertyGroup>
</Project> ResultsNow some errors occours on build:
I think the |
This issue still presists: in my net50 C# solution building with VS2019 I get no warnings with
and
but even with this last line a |
…028.1 (#2003) Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.XliffTasks From Version 9.0.0-beta.23527.4 -> To Version 9.0.0-beta.23528.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Because:
When I use a
netcoreapp2.x
with a project reference to anetstandard2.x
project and I set theBaseIntermediateOutputPath
, then the build/publish failed with this error:Steps to reproduce:
dotnet new classlib --name dotnetcore-lib --output src/dotnetcore-lib
dotnet new web --name aspnetcore --output src/aspnetcore
class lib
as reference toweb app
dotnet add .\src\aspnetcore\aspnetcore.csproj reference .\src\dotnetcore-lib\dotnetcore-lib.csproj
BaseIntermediateOutputPath
) => that works 👍BaseIntermediateOutputPath
) => that fails 👎What the hell we make it wrong?
Related issues
The text was updated successfully, but these errors were encountered: