dotnet / dotnet/project-system

Macros $(DevEnvDir), $(SolutionFileName), $(SolutionPath), $(SolutionDir), $(SolutionName), $(SolutionExt) are not defined during publish. Worked fine during build.

Open
#2,983 10 comments 4 reactions 0 assignees View on GitHub
Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

Tested on MS VS 2017 Community 2017, version 15.4.4, MS .NET Framework 4.7.02046.

A part of the code in .csproj:

```xml


netcoreapp2.0




```

There are targets with events executed after targets: BeforePublish, AfterPublish and used macros are not defined during publish.

```xml

















```

On a publish output are undefined macros: $(DevEnvDir), $(SolutionFileName), $(SolutionPath), $(SolutionDir), $(SolutionName), $(SolutionExt). These macros are undefined only while publish is executed. These macros are defined and work fine while a build is executed and in .csproj are targets with an option AfterTarget and targets BeforeBuild, PreBuildEvent, PostBuildEvent, AfterBuild.
Other targets like $(OutDir), $(ProjectPath), $(ProjectName) are defined and work fine in publish and build. Isn't macros be defined during publish as during build?

> Restoring NuGet packages...
> To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
> 1>------ Build started: Project: TradingCore, Configuration: Release Any CPU ------
> 1>TradingCore -> D:\Projects\Trading\TradingCore\bin\Release\netcoreapp2.0\TradingCore.dll
> 2>------ Publish started: Project: TradingCore, Configuration: Release Any CPU ------
> Connecting to D:\Projects\!Publish\Trading\Production\Release\TradingCore...
> echo Target: BeforePublishEvents executed AfterTarget: BeforePublish
> Target: BeforePublishEvents executed AfterTarget: BeforePublish
> echo TargetDir: D:\Projects\Trading\TradingCore\bin\Release\netcoreapp2.0\
> TargetDir: D:\Projects\Trading\TradingCore\bin\Release\netcoreapp2.0\
> echo ProjectDir: D:\Projects\Trading\TradingCore\
> ProjectDir: D:\Projects\Trading\TradingCore\
> echo DevEnvDir: *Undefined*
> DevEnvDir: *Undefined*
> echo SolutionFileName: *Undefined*
> SolutionFileName: *Undefined*
> echo SolutionPath: *Undefined*
> SolutionPath: *Undefined*
> echo SolutionDir: *Undefined*
> SolutionDir: *Undefined*
> echo SolutionName: *Undefined*
> SolutionName: *Undefined*
> echo SolutionExt: *Undefined*
> SolutionExt: *Undefined*
> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705,1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;RELEASE;NETCOREAPP2_0 /errorendlocation /preferreduilang:en-US /reference:C:\Users\st....\AppData\Local\Temp\.NETCoreApp,Version=v2.0.AssemblyAttributes.cs" obj\Release\netcoreapp2.0\TradingCore.AssemblyInfo.cs /warnaserror+:NU1605
> TradingCore -> D:\Projects\Trading\TradingCore\bin\Release\netcoreapp2.0\TradingCore.dll
> "dotnet" exec --runtimeconfig "D:\Projects\Trading\TradingCore\bin\Release\netcoreapp2.0\TradingCore.runtimeconfig.json" --depsfile "D:\Projects\Trading\TradingCore\bin\Release\netcoreapp2.0\TradingCore.deps.json" "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.1\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll" @"obj\Release\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"
> TradingCore -> D:\Projects\Trading\TradingCore\obj\Release\netcoreapp2.0\PubTmp\Out\
> echo Target: AfterPublishEvents executed AfterTarget: AfterPublish
> Target: AfterPublishEvents executed AfterTarget: AfterPublish
> echo TargetDir: D:\Projects\Trading\TradingCore\bin\Release\netcoreapp2.0\
> TargetDir: D:\Projects\Trading\TradingCore\bin\Release\netcoreapp2.0\
> echo ProjectDir: D:\Projects\Trading\TradingCore\
> ProjectDir: D:\Projects\Trading\TradingCore\
> echo DevEnvDir: *Undefined*
> DevEnvDir: *Undefined*
> echo SolutionFileName: *Undefined*
> SolutionFileName: *Undefined*
> echo SolutionPath: *Undefined*
> SolutionPath: *Undefined*
> echo SolutionDir: *Undefined*
> SolutionDir: *Undefined*
> echo SolutionName: *Undefined*
> SolutionName: *Undefined*
> echo SolutionExt: *Undefined*
> SolutionExt: *Undefined*
> Web App was published successfully file:///D:/Projects/!Publish/Trading/Production/Release/TradingCore
>
> ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
> ========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.