我想对自定义文件使用配置转换,如果将???
替换为MSDeployPublish
,则Preview
功能不起作用,它将替换解决方案中的本地文件。但是,发布可以在不使用Preview
的情况下进行,而保持本地文件不变。
配置文件:
AppSettings.config
└AppSettings.Test.config
└AppSettings.Stage.config
└AppSettings.Release.config
ConnectionString.config
└ConnectionString.Test.config
└ConnectionString.Stage.config
└ConnectionString.Release.config
将转换用于预览的目标的正确名称是什么(不更改解决方案中的文件)?使用WebDeploy进行预览时web.config
的工作方式
<Target Name="???">
<TransformXml Source="App_Config\AppSettings.config" Destination="App_Config\AppSettings.config" Transform="App_Config\AppSettings.$(Configuration).config" />
<TransformXml Source="App_Config\ConnectionStrings.config" Destination="App_Config\ConnectionStrings.config" Transform="App_Config\ConnectionStrings.$(Configuration).config" />
</Target>
我不想使用SlowCheetah之类的扩展,而只是内置功能。</ p>
<Target Name="Build">
也可以
我已成功发布而未更改本地配置文件:
Destination="$(_PackageTempDir)\App_Config\ConnectionStrings.config"
但是预览仍然不能改变配置(同样,当我定义输出消息时,它也不会出现)。在发布屏幕中单击“预览”时会发生什么黑魔法?
我尝试了以下目标:TransformWebConfigCore
,CopyAllFilesToSingleFolderForPackage
,GatherAllFilesToPublish
答案 0 :(得分:0)
我做到了。
目标名称应该是不存在的自定义名称。然后应将from tkinter import *
operator = ''
current_problem = ''
# Function to change text in workspace
def append_to_workspace(item):
""" Add item to workspace StringVar. """
if not isinstance(item, str):
item = str(item)
ws_var.set(ws_var.get() + item)
# Functions to change text in workspace
def add():
global current_problem
current_problem = current_problem + '+'
workspace.config(text = current_problem)
operator = 'A'
def subtract():
global current_problem
current_problem = current_problem + '-'
workspace.config(text = current_problem)
operator = 'S'
def divide():
global current_problem
current_problem + current_problem + '÷'
workspace.config(text = current_problem)
operator = 'D'
def multiply():
global current_problem
current_problem = current_problem + '×'
workspace.config(text = current_problem)
operator = 'M'
def num1():
global current_problem
current_problem = current_problem + '1'
workspace.config(text = current_problem)
# Create the main Tkinter Window
window = Tk()
window.title('Calculator')
# Add an empty Label for the workspace, place it in grid
ws_var = StringVar(value='')
workspace = Label(window, width=25, height=1, textvariable=ws_var)
workspace.grid(row=0, column=0)
# Operator keypad
operators = Frame(window)
add_button = Button(operators, text='+', width=2, command=add)
add_button.grid(row=1, column=0)
subtract_button = Button(operators, text='-', width=2, command=subtract)
subtract_button.grid(row=1, column=1)
divide_button = Button(operators, text='÷', width=2, command=divide)
divide_button.grid(row=1, column=2)
multiply_button = Button(operators, text='×', width=2, command=multiply)
multiply_button.grid(row=1, column=3)
operators.grid(row=1)
# Numeric keypad
numbers = Frame(window)
button7 = Button(numbers, text='7', width=2, command=lambda: append_to_workspace(7))
button7.grid(row=0, column=0)
button8 = Button(numbers, text='8', width=2, command=lambda: append_to_workspace(8))
button8.grid(row=0, column=1)
button9 = Button(numbers, text='9', width=2, command=lambda: append_to_workspace(9))
button9.grid(row=0, column=2)
button4 = Button(numbers, text='4', width=2, command=lambda: append_to_workspace(4))
button4.grid(row=1, column=0)
button5 = Button(numbers, text='5', width=2, command=lambda: append_to_workspace(5))
button5.grid(row=1, column=1)
button6 = Button(numbers, text='6', width=2, command=lambda: append_to_workspace(6))
button6.grid(row=1, column=2)
button1 = Button(numbers, text='1', width=2, command=lambda: append_to_workspace(1))
button1.grid(row=2, column=0)
button2 = Button(numbers, text='2', width=2, command=lambda: append_to_workspace(2))
button2.grid(row=2, column=1)
button3 = Button(numbers, text='3', width=2, command=lambda: append_to_workspace(3))
button3.grid(row=2, column=2)
button0 = Button(numbers, text='0', width=2, command=lambda: append_to_workspace(0))
button0.grid(row=3, column=0, columnspan=3)
numbers.grid(row=2)
window.mainloop()
属性指定为 AfterTargets
。此目标几乎发生在链的末端,并确保创建Package
目录。
转换在包目录中完成。这样可以确保在使用webdeploy进行预览时,它将正确比较文件,并且不会在源代码管理中更改本地文件。
这是定义:
$(_PackageTempDir)
当然可以有一种更好的方法:在<Target Name="CustomConfigTransform" AfterTargets="Package">
<TransformXml Source="App_Config\AppSettings.config" Destination="$(_PackageTempDir)\App_Config\AppSettings.config" Transform="App_Config\AppSettings.$(Configuration).config" />
<TransformXml Source="App_Config\ConnectionStrings.config" Destination="$(_PackageTempDir)\App_Config\ConnectionStrings.config" Transform="App_Config\ConnectionStrings.$(Configuration).config" />
</Target>
的目标CollectWebConfigsToTransform
中,它应该以某种方式知道会有更多的配置文件要转换。但是目前还不知道。