msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

$(PublishDir) value is wrong

Open deastr opened this issue 9 years ago • 5 comments

I'm using Visual Studio.NET 2017 RC4. In my project the publish Target Location is set to "bin\Debug\PublishOutput" but following code is giving me "bin\Debug\net452\win10-x64\publish\" output whether I'm just building the project or publishing it:

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="echo $(PublishDir)" />
</Target>
  <PropertyGroup>
    <TargetFramework>net452</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  </PropertyGroup>
dotnet --info
.NET Command Line Tools (1.0.0-rc4-004771)

Product Information:
 Version:            1.0.0-rc4-004771
 Commit SHA-1 hash:  4228198f0e

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

deastr avatar Mar 07 '17 10:03 deastr

It seems that publishing does not respect <Configuration/> inside .pubxml

This might be a VS tooling issue but here is another side effect:

Publish will fail when:

  • Current configuration differs from <Configuration/> inside .pubxml
  • <GeneratePackageOnBuild/> is set to true inside the project file.
2>------ Publish started: Project: Xyz, Configuration: Debug Any CPU ------
2>The "PackTask" task failed unexpectedly.
2>System.IO.FileNotFoundException: File not found: '(....)\Xyz\bin\Release\netstandard1.6\Xyz.dll'.
2>   at NuGet.Packaging.PackageBuilder.AddFiles(....)

Steps to reproduce:

  • Create a .NET Core project
  • Tick the Project Properties → Package → Generate NuGet package on build checkbox
  • Create a publish profile and leave the publish configuration set to Release
  • Set the solution configuration to Debug
  • Click 'Publish'

mdschweda avatar Mar 23 '17 14:03 mdschweda

I see, it is two completely separate msbuild scripts. The IDE should execute

msbuild /p:Configuration=<PublishConfiguration> ... though

mdschweda avatar Mar 24 '17 12:03 mdschweda

Team triage: closing due to age. If you're still seeing this problem, please let us know and we can reactivate it.

rainersigwald avatar Apr 22 '20 16:04 rainersigwald

msbuild issue continues the pubxml file has the element PublishDir that is ignored. This element hold the location to publish to. Compiler uses the value and publishes to that folder location. msbuild ignores the value

Dale4 avatar Jul 28 '22 19:07 Dale4

@Dale4: Did you solve the problem?

Seems like a lot of people are having the problem that PublishDir is irgnored when using msBuild. Publishing from Visual Studio (2022) just works fine.

christian-knollmann avatar Jan 05 '24 09:01 christian-knollmann