When i publish a Asp.Net core with angular app i get an unwanted folder under the wwwroot
But i want the content of that folder directly inside wwwroot.
I think the problem is in this piece of the project csproj file
<!--Include the newly-built files in the publish output-->
<ItemGroup>
<DistFiles Include="$(SpaRoot)dist\**; $(SpaRoot)dist-server\**" />
<ResolvedFileToPublish Include="#(DistFiles->'%(FullPath)')" Exclude="#(ResolvedFileToPublish)">
<RelativePath>wwwroot\%(RecursiveDir)%(FileName)%(Extension)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</ResolvedFileToPublish>
</ItemGroup>
I just needed to change the "outDir" in the tsconfig.json
Related
Want to publish ASP.NET Core 3 project to single exe. How can i include/exclude wwwroot(js/css) to exe file?
Thanks!!
If you want to publish project exclude some files ,you can add these code in xxx.csproj
<ItemGroup>
<Content Update="wwwroot/css/*" CopyToPublishDirectory="Never" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot/js/*" CopyToPublishDirectory="Never" />
</ItemGroup>
Then js and css files are excluded.
I've developed a custom NuGet which uses DotNetProjects.DotNetSiemensPLCToolBoxLibrary. DotNet library includes external dlls that are copied into the output directory following these statements:
<Content Include="..\externalDlls\libnodave_jfkmod.dll">
<Pack>true</Pack>
<PackageCopyToOutput>true</PackageCopyToOutput>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="..\externalDlls\libnodave_jfkmod64.dll">
<Pack>true</Pack>
<PackageCopyToOutput>true</PackageCopyToOutput>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
However, when my custom Nuget is used in another project, DotNet dlls are shown on project tree but not copied into the output directory.
nuget use example
If I set manually that these dlls will always be copied into output directory it works. It is posible to do so in the .csproj of my custom nuget?.
You can modify the .nuspec file instead of csproj file.
<files>
<!-- the dlls are copied from src to target-->
<file src="lib\**" target="lib/{framework name}[{version}]" />
</files>
The link: Support multiple .NET versions
I created a class library project and put my SQLite database in it, and set these lines in the .csproj file:
<ItemGroup>
<Content Include="Data\DataBase\locations.db">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
If I locally reference that class library to my main project (ASP.NET Core), it works fine and on every build it will copy the database file to this directory:
***\bin\Debug\net5.0\Data\DataBase
But when I publish the class library to NuGet, and install it in my main project, it doesn't copy the file.
Any help why this is happening and what should I do?
This is my package in NuGet package explorer
Just find out the answer
<ItemGroup>
<Content Include="Data\DataBase\locations.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
</ItemGroup>
This line will do the job
<PackageCopyToOutput>true</PackageCopyToOutput>
In my .csproj file, I am creating directories containing files, and these directories are being created in the main project directory as intended. For certain reasons, I cannot generate these directories in bin\debug. However, I do not want the files generated in the directories to be included in the project, as I do not want them to be checked in.
How can I exclude the files from my project automatically through msbuild?
For reference, I have tried the following, and though the files get generated as expected, they are still being added to the project unintentionally:
<Target Name="BuildThings" AfterTargets="Build" BeforeTargets="GatherStagingFiles" Inputs="#(Compile)" Outputs="$(GeneratedFilesDirectory)">
<Exec WorkingDirectory="$(MSBuildProjectDirectory)" Command="$(ToolPath) buildpackage -InputDir:$(MSBuildProjectDirectory)\$(OutDir) -OutputDir:$(MSBuildProjectDirectory)\$(GeneratedFilesDirectory)" />
</Target>
<Target Name="HideFiles" DependsOnTargets="BuildThings">
<ItemGroup>
<GeneratedFiles Include="$(MSBuildProjectDirectory)\$(GeneratedFilesDirectory)\file.txt">
<InProject>false</InProject>
</GeneratedFiles>
</ItemGroup>
</Target>
In my C# project I have some .docx,.xlsx,*.jpg files in an folder, I want to make all these files as Content and while Setup and Deployment Project I want to add all these files as Content Output for That I have done follwing steps:
Unload Project from property window and then selected to Edit .csproj file.
Added below lines in <ItemGroup> to make all files in folder as Content and linked them to a folder
<Content Include="Lib\MyApp\Support\**\*.*">
<Link>Support\%(RecursiveDir)%(FileName).%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\MyApp\Files\**\*.*">
<Link>Files\%(RecursiveDir)%(FileName).%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Reload Project
After reloading project I got lots of warning like
Warning 34 The file 'Lib\MyApp\Files\abc.bmp' could not be added to
the project. Cannot add a link to the file
D:\MyApp\Lib\MyApp\Files\abc.bmp. This file is within the project
directory tree.
I have Excluded the Lib folder from project, Why I am getting such warnings what I am doing wrong? Is it safe to ignore such warnings.
Update
After modifying csproj file to this
<Content Include="Lib\QOES\Support\**\*.*">
<Link>Support\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="Lib\QOES\Files\**\*.*">
<Link>Files\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
after adding <Visible>false</Visible> removed warnings, but is this correct way?
Adding <Visible>false</Visible> seems to be a very convenient solution to get rid of the Visual Studio warning:
The file <filename> could not be added to the project. This file is
within the project directory tree.
According to: MSDN: The file 'file' could not be added to the project, one of the reasons is relative paths being ambiguous. Meaning you have the file path Lib/MyApp/Files/abc.bmp both as a file path in your project folder as well as on your D: drive leading to ambiguity. That is my guess. Adding files by hand to the project folder can lead to issues.
In my case where I wanted to place a native binary aside of the executable, using <TargetPath> instead of <Link> worked:
<Content Include="Lib\somelibrary.dll">
<TargetPath>somelibrary.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>