C# 围绕using的多目标和定义的常量
我有一个项目,我在其中设置了项目文件,如下所示:C# 围绕using的多目标和定义的常量,c#,msbuild,C#,Msbuild,我有一个项目,我在其中设置了项目文件,如下所示: <PropertyGroup> <TargetFrameworks>netstandard2.0;net472</TargetFrameworks> </PropertyGroup> <!-- .NET Standard 2.0 references, compilation flags and build options --> <PropertyGroup
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
</PropertyGroup>
<!-- .NET Standard 2.0 references, compilation flags and build options -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>NETCORE;</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
</ItemGroup>
<!-- .NET 4.7.2 references, compilation flags and build options -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'net472'">
<DefineConstants>NETFULL</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net472'">
<Content Include="3rd Party\SomeThirdParty.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
</ItemGroup>
然而,我得到一个netstandard2.0版本的编译错误
“找不到命名空间'SomeThirdParty.namespace'的类型”
我的理解是,只有NETFULL构建才会看到using语句,并尝试使用它进行编译
有人能帮上忙吗?我知道你从哪个网站上得到这个消息,但条件和评论中的间隔完全相同,但是,这应该适用于.net 4.7.2,注意另一个.net framework版本将不起作用,如果你认为这是正确的,关闭应用程序,删除bin和obj目录,因为事情可能会不一致(只是猜测)我想知道为什么在下载和编译之前删除所有内容的build box会出现同样的问题?有什么想法吗?@StephenCossgrove你有两个同名账户吗?
using System;
#if NETFULL
using SomeThirdParty.Namespace;
#endif
using mynamespace
{
public class MyClass
{
}
}