$(PublishDir) value is wrong
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
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 buildcheckbox - Create a publish profile and leave the publish configuration set to
Release - Set the solution configuration to
Debug - Click 'Publish'
I see, it is two completely separate msbuild scripts. The IDE should execute
msbuild /p:Configuration=<PublishConfiguration> ... though
Team triage: closing due to age. If you're still seeing this problem, please let us know and we can reactivate it.
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: 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.