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


原文链接:https://github.com/dotnet/project-system/issues/2983

 

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

 

A part of the code in .csproj:

 

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>

     <TargetFramework>netcoreapp2.0</TargetFramework>

  </PropertyGroup>

  <ItemGroup>

     <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />

  </ItemGroup>

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

 

<Target Name="BeforePublishEvents" AfterTargets="BeforePublish">

  <Exec Command="echo Target: BeforePublishEvents executed AfterTarget: BeforePublish" />

  <Exec Command="echo TargetDir: $(TargetDir)" />

  <Exec Command="echo ProjectDir: $(ProjectDir)" />

  <Exec Command="echo DevEnvDir: $(DevEnvDir)" />

  <Exec Command="echo SolutionFileName: $(SolutionFileName)" />

  <Exec Command="echo SolutionPath: $(SolutionPath)" />

  <Exec Command="echo SolutionDir: $(SolutionDir)" />

  <Exec Command="echo SolutionName: $(SolutionName)" />

  <Exec Command="echo SolutionExt: $(SolutionExt)" />

</Target>

<Target Name="AfterPublishEvents" AfterTargets="AfterPublish">

  <Exec Command="echo Target: AfterPublishEvents executed AfterTarget: AfterPublish" />

  <Exec Command="echo TargetDir: $(TargetDir)" />

  <Exec Command="echo ProjectDir: $(ProjectDir)" />

  <Exec Command="echo DevEnvDir: $(DevEnvDir)" />

  <Exec Command="echo SolutionFileName: $(SolutionFileName)" />

  <Exec Command="echo SolutionPath: $(SolutionPath)" />

  <Exec Command="echo SolutionDir: $(SolutionDir)" />

  <Exec Command="echo SolutionName: $(SolutionName)" />

  <Exec Command="echo SolutionExt: $(SolutionExt)" />

</Target>

On a publish output are undefined macros: 

(SolutionFileName), 

(SolutionDir), 

(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 

(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 ==========

 

kirsan31, zahirtezcan-bugs, okumura-pico, and LeadManPL reacted with thumbs up emoji

@Pilchie

Member

Pilchie commented on Nov 28, 2017

@livarcocc - is this also an SDK issue? In general, I don't think these are reliably set in command line builds anyway, so it's probably best not to depend on them...

 

@livarcocc

livarcocc commented on Nov 28, 2017

The SDK does not set these properties. It is set somewhere else I believe.

 

@nguerrera can you check?

 

@Pilchie

Member

Pilchie commented on Dec 5, 2017

@stachu99 my guess is that this is related to #2982. In the case where they are undefined, it's because they are being launched by the dependency from "dotnet publish" to build, but outside of the IDE, these variables are not set.

 

@nguerrera

Contributor

nguerrera commented on Dec 5, 2017

cc @mlorbetske A publish initiated from VS should have the same properties as a build initiated by VS. I have seen that publish does not do this for SolutionDir and it actually triggers different behavior in the SDK resolver. If that's what's happening here, I think the VS code that kicks of publish should be changed to match how VS kicks off build.

 

@mlorbetske

mlorbetske commented on Dec 5, 2017

@vijayrkn

 

@Pilchie Pilchie added the Area-New-Project-System label on Jan 4, 2018

@Pilchie Pilchie added this to the Unknown milestone on Jan 4, 2018

@jjmew jjmew added Triage-Approved Reviewed and prioritizedand removed Triage-Approved Reviewed and prioritizedlabels on Jan 15, 2019

@davkean davkean removed the Project-System-CPS label on Jul 18, 2019

@dustinlacewell

dustinlacewell commented on Aug 12, 2019

What's going on with this issue...?

 

@nguerrera

Contributor

nguerrera commented on Aug 12, 2019

Ping, @vijayrkn This seems to be an issue with Publish in VS not setting the same properties on build as a regular build.

 

@vijayrkn

Contributor

vijayrkn commented on Aug 13, 2019

We do pass all the properties that we get from the project system during publish. I see that this issue was created an year before. Does this still happen?

 

@dustinlacewell

dustinlacewell commented on Aug 13, 2019 • 

You definitely don't get things like $(SolutionDir) when doing dotnet build or dotnet publish in my experience. It would be super great if dotnet and Visual Studio were unified.

 

@nguerrera

Contributor

nguerrera commented on Aug 14, 2019

You should get $(SolutionDir) and the like on the command line if you are building a .sln, but not if you are building an individual project. Projects don't know what solution they are in and they could be in more than one so there's no real way to make that just work if you are operating on a single project on the command line.

 

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
张国生
上一篇:Fastreport页码设置
下一篇:C# 静态类获得 机密配置
评论列表

发表评论

评论内容
昵称:
验证码:
验证码
关联文章

Macros $(DevEnvDir), $(SolutionFileName), $(SolutionPath), $(SolutionDir), $(SolutionName), $(SolutionExt) are not defined during publish. Worked fine during build
Visual Studio (VS) 使用Gulp报错 ReferenceError: primordials is not defined
vue typescript 使用big.js编译build会报错
vue-cli4构建build时删除console和debugger
.NET Core中使用编码GB2312报错‘GB2312‘ is not a supported encoding name 解决方案
项目编译publish
EF MySQL取值时出错: Specified cast is not valid
.netcore 打开SQLite数据库失败:You need to call SQLitePCL.raw.SetProvider(). If you are using a bundle package, this is done by calling SQLitePCL.Batteries.Init().”
.NETCore 运行项目报错:Could not load file or assembly ***
.Net启动程序报错:It was not possible to find any compatible framework version
Python读取excel xlrd读取xlsx报错:Excel xlsx file; not supported
支付宝获取用户信息时,提示 对不起,访问出错了 E004:AUTH_REDIRECT_URL_NOT_IN_WHITE
VUE使用sass提示在sass文件中提示Syntax Error : this.getOptions is not a function
IIS服务器访问woff2字体文件报错 net::ERR_ABORTED 404 (Not Found)
TinyMCE
C# Roslyn编译csproj项目 使用Roslyn编译整个C#项目
使用.NET 6开发TodoList应用(30)——实现Docker打包和部署
vue3+vist 打包空白
使用.NET 6开发TodoList应用(9)——实现PUT请求
bat脚本:生成项目并自动加壳发布

热门标签
.NET Core .NET Reactor ag-grid AI发布 api安全 ASP.NET Core C#DLL加密 C#播放声音 C#代码混淆 C#代码加密 ChromeDriver Codex DateTime DBeaver devexpress devTool DLL混淆 edge.js EF EFCore Electron element-ui el-form el-table excel FastReport FileStream FolderBrowerDialog FolderSelectDialog form提交 git gridcontrol gridview input javascript json字符串 JS转换对象JSON jwt JWT授权 linq log Math MCP mitmproxy MVC MySQL Navicat netstat nginx node_modules NSwag Nuget Nuget镜像 number PowerShell pyinstaller python pythoncom python爬虫 python抓包 pywin32 redis Requests-html RestSharp Selenium sql SQL Server Swagger to-cms Visual Studio VSCode vue VueRouter vue路由 VUE页面通讯 Webpack Windows Windows服务 winform wmi xlrd yaml YESCMS YESWEB开发框架 白象 表单提交 播放声音 打开URL 代码混淆 弹窗提醒 端口占用 对象转换 分布式 公共字典 机器码 进程排查 静态资源 开发指南 路由参数 密钥 配置教程 配置文件 权限 人工智能 任务 任务调度 日期间隔 日志 日志记录 省市区 授权验证 数据库 四舍五入 文案 文件读取 文件夹选择 文件目录选择 问题排查 行政区域数据 页面通讯 中间件 CSharp 事务锁 工单系统 并发控制 重复提交 CMS Markdig Markdown markdown-it marked 技术选型 VS Code 开发工具 源代码管理 版本控制 Docker PostgreSQL 时区 部署排查 CMS架构 EF Core 主题系统 二次开发 插件系统 容器 运维命令 镜像清理 Linux NAS 远程挂载 飞牛 fnOS S/4HANA SAP GUI SAP HANA SAP R/3 SAP入门 SAP版本 ERP SAP SAP MM 库存管理 物料管理 采购管理 入门教程 SAP S/4HANA SPRO 企业结构 采购组织 MM01 物料主数据 物料类型 BP分组 业务伙伴 供应商主数据 ME41 RFQ 库存物料 采购流程 ME51 消耗性物料 科目分配 采购申请 AC03 ML81N 外部服务 服务主数据 Business Partner SAP培训 ME51N MM模块 Lean Services MM-SRV 外部服务采购 PIR 供应来源 采购主数据 采购信息记录 ME31K 框架协议 计划协议 采购合同 ME01 供应来源确定 货源清单 MEQ1 供应源确定 配额安排 配额评分 MD04 MD21 MRP 计划文件 需求计划 批量程序 MD01N MD02 MRP Live MD05 MM 物料计划 优化采购 供应源 采购订单 ME2A 供应商确认 采购监控 Flexible Workflow 凭证释放 采购审批 释放策略 实地盘点 物料凭证 货物移动 MIGO 收货 移动类型 已撤回 供应商退货 货物发出 STO 库存转储 转移过账 生产订单 预留
联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码