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 库存转储 转移过账 生产订单 预留 GR/IR MIRO 供应商发票 物流发票校验 OMR2 税码 FI PP SD 实操教程 MRBR OMR6 发票差异 交货成本 后续借记 MI01 实物盘点 盘点差异 公司代码 工厂 组织结构 OMS2 主数据定制 自动科目确定 BP角色 CVI 伙伴确定 编号范围 凭证类型 字段选择 FBN1 OMBT OMC2 会计凭证 OMJJ BOM 委外加工 项目类别L MRKO 供应商寄售 特殊库存K MRKON PIPE Pipeline 特殊库存P ERS MRIS 发票计划 周期性结算 里程碑付款 变更追踪 版本管理 采购凭证 SFTP WebDAV 网盘 飞牛fnOS AMPL HERS MPN 中文教程 库存确定 可用性检查 缺件检查 Output Management 消息确定 输出确定 分割评估 库存计价 评估类别 评估类型 PB00 RM0000 条件技术 采购定价 MM-FI集成 OBYC 库存估价 文本类型 文本采用 EFB EVO MSV SU3 用户参数 发票校验 合同参照 履约保留款 特别总账 预付款 Fiori Launchpad SAP Fiori 应用导航 用户体验 LSMW LTMC Migration Cockpit 数据迁移 BRFplus OPD Output Control My Inbox 审批流程 灵活工作流 SAP PP 外部加工 SAP QM 检验批 质量信息记录 采购收货 SAP PM 维护BOM 维护订单 SAP SD SAP Service 端到端流程 MM模块培训 FI-MM集成 供应商管理 审批配置 FICO入门 SAP FICO 财务配置 供应商税务 预扣税 House Bank 银行对账 客户清账 应收账款 FI控制 验证与替代 印度 GST 税务配置 F110 FBZP EWM入门 SAP EWM 仓库管理 OX14 成本核算 物料评估 后勤配置 物料组 价值更新 数量更新 PP-PI 流程制造 生产计划 容差配置 SAP事务码 SAP基础 TCODE Basis 事务代码 MMNR 编号区间 采购实操 组织架构 OMSF SAP实操 FI配置 端口修改 密码设置 数据库配置 远程访问 ABAP基础 SAP ABAP 内表 变量定义 常量 数据类型 ABAP SAP开发 变量 基础语法 系统变量 结构体 字符串处理 循环语句 控制语句 DDIC SE11 数据字典 透明表 ABAP开发 ALE EDI IDoc 增强技术 ABAP内表 HASHED TABLE SORTED TABLE STANDARD TABLE 基本概念 性能优化 PARAMETERS SELECT-OPTIONS SELECTION-SCREEN 报表程序 选择屏幕 F4帮助 Report事件 输入校验 ABAP SQL ABAP语法 Open SQL SELECT 数据库访问 IKuai IP修改 PVE 网络配置 虚拟化 AI 编程助手 ClaudeCode OpenRouter
联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码