Skip to content

dotnet msbuild /t:Pack puts the nupkg in a TFM-specific directory #318

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

Closed
TheRealPiotrP opened this issue Oct 25, 2016 · 7 comments · Fixed by #351
Closed

dotnet msbuild /t:Pack puts the nupkg in a TFM-specific directory #318

TheRealPiotrP opened this issue Oct 25, 2016 · 7 comments · Fixed by #351
Assignees
Labels
Milestone

Comments

@TheRealPiotrP
Copy link
Contributor

TheRealPiotrP commented Oct 25, 2016

#316 Repro:

csproj

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
  <PropertyGroup>
    <TargetFramework>netstandard1.5</TargetFramework>
    <NoWarn>$(NoWarn);CS1591</NoWarn>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <DocumentationFile>$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
    <EmbeddedResource Include="**\*.resx" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
    <EmbeddedResource Include="compiler\resources\**\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk">
      <Version>1.0.0-alpha-20161019-1</Version>
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
    <PackageReference Include="NETStandard.Library">
      <Version>1.6.0</Version>
    </PackageReference>
  </ItemGroup>
  <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
    <DefineConstants>$(DefineConstants);NETSTANDARD1_5</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
  </PropertyGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

run dotnet pack or dotnet msbuild /t:Pack

Expected

nupkg is generated in bin/Debug/projectName.nupkg

Actual

nupkg is generated in bin/Debug/netstandard1.5/projectName.nupkg

@TheRealPiotrP
Copy link
Contributor Author

@TheRealPiotrP TheRealPiotrP added this to the 1.0 RC milestone Oct 25, 2016
@srivatsn
Copy link
Contributor

@rohit21agrawal - I assume this is not expected? Can you take a look?

@srivatsn srivatsn modified the milestones: 1.0 Preview, 1.0 RC Oct 25, 2016
@eerhardt
Copy link
Member

This is because /t:Pack uses the $(OutputPath) property to where to stick the packed nupkg.

When the project is multi-targeted, the $(OutputPath) property changes depending on whether it is building the "inner" or "outer" build. During the "inner" build, $(OutputPath) == bin\Debug\TFM. During the "outer" build, $(OutputPath) == bin\Debug. Since pack runs in the outer build, the nupkg gets placed to bin\Debug.

However, the project above is not multi-targeted. It only targets <TargetFramework>netstandard1.5</TargetFramework>. Thus there is no "outer" build. And when pack runs, the $(OutputPath) == bin\Debug\netstandard1.5.

If we feel we need to fix this, we could make a new property for /t:Pack to use called $(PackOutputPath) that would get defaulted to the $(OutputPath) before we appended the TFM to the end of it: https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.TargetFrameworkInference.targets#L86

@srivatsn
Copy link
Contributor

If we have a single TFM project, should we even append the TFM to outputpath? That's unnecessary directory depth isn't it?

@rohit21agrawal
Copy link
Contributor

i like the idea of $(PackOutputPath)

@eerhardt
Copy link
Member

If we have a single TFM project, should we even append the TFM to outputpath? That's unnecessary directory depth isn't it?

Not saying this makes it "right", but this is what the CLI did as well. Your output path was always consistent whether you targeted one or many TFMs.

@nguerrera
Copy link
Contributor

Not saying this makes it "right", but this is what the CLI did as well. Your output path was always consistent whether you targeted one or many TFMs.

I'm not saying it's right either, but it certainly makes the code simpler. Given that this is how it has always worked, I'd say let's keep it that way.

The nuget path does need to be consistent too, though. @eerhardt's approach of PackOutputPath defaulting to OutputPath before TFM change is elegant. +1 to that.

@nguerrera nguerrera assigned nguerrera and unassigned rohit21agrawal Nov 2, 2016
sbomer pushed a commit to sbomer/sdk that referenced this issue Sep 19, 2017
Fix incorrect forcedPackageRank comparison in ConflictResolver
mmitche pushed a commit to mmitche/sdk that referenced this issue Jun 5, 2020
…otnet#318)

* Add a property that indicates that the Web.Sdk is being referenced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants