Copy file to build directory

How would I make it so a file I added to the program files would get copied to the build directory when the program is built?
11 Replies
Angius
Angius2mo ago
In VS, right-click the file, open properties, set it to copy always or copy if newer
Protogen Posting
Protogen PostingOP2mo ago
I'm in vs code there's no properties thingy
Angius
Angius2mo ago
Open the .csproj file then and add
<ItemGroup>
<Content Update="myfile.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Update="myfile.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Protogen Posting
Protogen PostingOP2mo ago
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<Content Update="testingprogram.ASS">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>ASS_Compiler</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<Content Update="testingprogram.ASS">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>ASS_Compiler</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
it doesn't seem to be copying it
No description
Angius
Angius2mo ago
It's not in bin/Debug/net8.0? Try
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ <CopyToPublishDirectory>Always</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ <CopyToPublishDirectory>Always</CopyToPublishDirectory>
Protogen Posting
Protogen PostingOP2mo ago
still no I'm also on linux if that's any help
Angius
Angius2mo ago
Shouldn't make a difference
Protogen Posting
Protogen PostingOP2mo ago
weird
Angius
Angius2mo ago
Uh,
<ItemGroup>
<None Update="foo.txt" CopyToOutputDirectory="Always" />
</ItemGroup>
<ItemGroup>
<None Update="foo.txt" CopyToOutputDirectory="Always" />
</ItemGroup>
? Or Content instead of None
Protogen Posting
Protogen PostingOP2mo ago
ok that worked thanks!!!
Angius
Angius2mo ago
Cool
Want results from more Discord servers?
Add your server