我正在使用新的.csproj文件格式。
我希望我的项目能够构建:
C:\发展\源\ DOTNET的\ BIN \ 64 \调试\
但它似乎隐含地增加了路径并将其构建在:
C:\发展\源\ DOTNET的\ BIN \ 64 \调试\ net46
有没有办法阻止它这样做?
我的项目是:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<Platforms>x64</Platforms>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutputPath>C:\Development\Source\DotNet\bin\x64\Debug\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="AssetManagement_Gen">
<HintPath>..\..\Development\Source\DotNet\bin\x64\Debug\AssetManagement_Gen.dll</HintPath>
</Reference>
<Reference Include="EXPLink">
<HintPath>..\..\Development\Source\DotNet\bin\x64\Debug\EXPLink.dll</HintPath>
</Reference>
<Reference Include="IvaraCommon">
<HintPath>..\..\Development\Source\DotNet\bin\x64\Debug\IvaraCommon.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\..\Development\Source\DotNet\bin\x64\Debug\NLog.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
</ItemGroup>
</Project>
如果我在visual studio中打开它,它也会显示&#34; net46&#34;附加到输出路径。
对于我的子孙后代,<OutputPath>
和<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
的组合可让您获得完全自定义的路径。
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<IsPackable>false</IsPackable>
<Platforms>x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\..\bin\x64\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\..\bin\x64\Release\</OutputPath>
</PropertyGroup>
答案 0 :(得分:6)
我找到了以下帖子:
https://compiledexperience.com/blog/posts/multi-targeting-output-path
如果要禁用此自动附加,例如,您将只使用一个目标框架,或者每个框架定义不同的输出路径,则可以使用AppendTargetFrameworkToOutputPath。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
</Project>