0

I have a set of sql scripts set as BuildAction=embedded resources and CopyToOutDirectory=CopyAlways.

It does not seem to copy to the bin directory.

I must have them as EmbeddedResources and not content.
Is there a way to do it?

2 Answers 2

1

EmbeddedResources are, as the name already suggests, "embedded" in the assembly, so they are not copied to the output directory anymore.

If you need it "both ways" you could use a post-build task like the following:

xcopy $(ProjectDir)\MyFile.ext $(TargetDir)\

but you would need to maintain this script if you add/remove files you need copied.
Also keep in mind, that if you change that file in the output directory the embedded resource you are using in your program is NOT changed.

Sign up to request clarification or add additional context in comments.

Comments

1

You can can use "Link" metadata to set your destination folder

For Example: Use this to copy a.dll to "bin" folder

    <EmbeddedResource Include="Resources\a.dll" Link="..\bin\a.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </EmbeddedResource>

for more reference visit : https://github.com/Microsoft/msbuild/issues/2795

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.