我在每次构建之前尝试复制链接文件时引用this article:
<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
<Copy SourceFiles="%(Content.Identity)"
DestinationFiles="%(Content.Link)"
SkipUnchangedFiles='true'
OverwriteReadOnlyFiles='true'
Condition="'%(Content.Link)' != ''" />
</Target>
这似乎不适用于新的.NET Core csproj工具。什么是等效的目标呢?
编辑:csproj内容示例
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Features>IOperation</Features>
<Configurations>Debug;Release;Template</Configurations>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\MyRefProject\ChangeTypes.cs" Link="ChangeTypes.cs" />
<Compile Include="..\MyRefProject\Parser.cs" Link="Parser.cs" />
<Compile Include="..\MyRefProject\Calculator.cs" Link="Calculator.cs" />
<Compile Include="..\MyRefProject\Converter.cs" Link="Converter.cs" />
</ItemGroup>
</Project>
答案 0 :(得分:1)
Traceback (most recent call last):
File "temp.py", line 41, in <module>
out = tf.cond(i_<max_para,get_output,get_output2)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/util/deprecation.py", line 316, in new_func
return func(*args, **kwargs)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 1894, in cond
orig_res_t, res_t = context_t.BuildCondBranch(true_fn)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/control_flow_ops.py", line 1752, in BuildCondBranch
original_result = fn()
File "temp.py", line 31, in get_output
out = gru(inputs)
File "temp.py", line 15, in __call__
out_fw, _ = self.gru_fw(inputs, initial_state=(self.init_fw,))
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/layers/base.py", line 636, in __call__
self.build(input_shapes)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/contrib/cudnn_rnn/python/layers/cudnn_rnn.py", line 357, in build
"opaque_kernel", initializer=opaque_params_t, validate_shape=False)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 1262, in get_variable
constraint=constraint)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 1097, in get_variable
constraint=constraint)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 427, in get_variable
return custom_getter(**custom_getter_kwargs)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/contrib/cudnn_rnn/python/layers/cudnn_rnn.py", line 290, in _update_trainable_weights
variable = getter(*args, **kwargs)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 404, in _true_getter
use_resource=use_resource, constraint=constraint)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 806, in _get_single_variable
constraint=constraint)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/variables.py", line 229, in __init__
constraint=constraint)
File "/home/search/snetP/virtual_bhavya/lib/python3.5/site-packages/tensorflow/python/ops/variables.py", line 342, in _init_from_args
"initializer." % name)
ValueError: Initializer for variable cudnn_gru/opaque_kernel/ is from inside a control-flow construct, such as a loop or conditional. When creating a variable inside a loop or conditional, use a lambda as the initializer.
应该在Condition
级别指定,但在这种情况下这不会有帮助,因为您无法使用元素元数据作为条件。
您还需要提供输出路径。您的示例只会将链接的内容复制到项目的目录中,而不是它的输出目录。
Target
<Target Name="CopyLinkedContentFiles" BeforeTargets="Build">
<Copy SourceFiles="%(Content.Identity)"
DestinationFiles="$(OutputPath)\%(Content.Link)"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true" />
</Target>
任务的文档可以是found here。
我使用Visual Studio 2017测试了两个简单的控制台项目。第二个项目包括几个文本文件。第一个项目还通过内容链接引用这些文件。这是第一个项目的Copy
文件:
.csproj