New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow copying empty directories with <Content> #1586
Comments
|
The referenced issue should address the fact that the ANCM cannot currently create the path specified in The suggestion here is still great imo: I'd like to be able to create empty folders without having to resort to ... |
|
We're struggling with this also, after the JSON to csproj migration. GuardRex, how does your CreateLogsFolder target work? I've tried exactly that, and the logs folder isn't created in the final default publish location of .\bin\Debug\PublishOutput. I suspect $PublishDir is that temporary publish location, before the final move? |
|
@WildBamboo That <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<WarningsAsErrors>true</WarningsAsErrors>
<OutputType>Exe</OutputType>
<Optimize Condition=" '$(Configuration)' != 'Debug' ">true</Optimize>
<MvcRazorCompileOnPublish Condition=" '$(Configuration)' == 'Release' ">true</MvcRazorCompileOnPublish>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="1.1.0" PrivateAssets="All" />
</ItemGroup>
<Target Name="CreateLogsFolder" AfterTargets="AfterPublish">
<MakeDir Directories="$(PublishDir)Logs" Condition="!Exists('$(PublishDir)Logs')" />
</Target>
</Project> |
|
If directories could be used as items, it would also be great if it were possible to use their timestamps for incremental compilation (=> usable as |
|
@guardrex I've just made a new ASP.NET Core Web Application (.NET Core) project, using the ASP.NET Core 1.1 empty template, and added your target. I published to the filesystem, default location, and no logs folder is present. So I dunno; works on your machine :) |
|
@dasMulli Can you think of a reason why it might not work? Does it need an entry point to work? @WildBamboo btw - the |
|
@guardrex, wwwroot tip noted; that was just how the template came. |
|
Once you think you understand how things work, VS comes along and does things differently It really publishes the app to If I understand it correctly, the logic for it lives somewhere in https://github.com/aspnet/websdk/tree/dev/src/Publish, maybe we can move this issue over there? |
|
@dasMulli So the reason it works for me is that I'm using VS Code! @WildBamboo Yes, open an issue over on |
|
However, I'm guessing the web targets would also need support for folders as items to get that out of the box - so we're back here. In the meantime, we can of course hook into file system publish: <Target Name="CreateLogsFolderOnFileSystem" AfterTargets="FileSystemPublish">
<MakeDir Directories="$(PublishUrl)Logs" Condition="!Exists('$(PublishUrl)Logs')" />
</Target> |
|
Thanks all. I can't see any issue related to the logs folder, so I created https://github.com/aspnet/websdk/issues/152 Currently using the workaround suggested by @dasMulli above, which works great for what we need right now. |
|
Ok, so publishing in VS is sorted now, but I'm guessing the So I've now got one target for cli/VSCode, and one for VS: I can go home now :) |
|
I have another problem with it - I cannot have empty AppData folder on publish. |
|
Slightly off target but I thought it worth mentioning this here as I got to this thread trying to resolve my problem 'How can I create a folder when I publish my MVC 4 app in VS Code'. The key to solving what you need to do is to look at the output of the publish process. I have a 'publish' process in my '.vscode/tasks.json' file thus: When this runs, open the terminal window (click on the 'Building..' in the taskbar), and check the headings in the output window printed in blue. When I was building an old MVC 4 app I got headings like this: To trigger my post publish task to create an output folder, I created an section like this in my .csproj file: N.B. The name of the event in AfterTargets="XYZ" needs to match the name of the event observed earlier. |
This issue has been inspired by dotnet/cli#2911. In short, if I specify something like this:
MSBuild will throw an error saying that the
Copytask does not support copying directories. I can put in a glob, but if there are no files, nothing gets copied out (with a glob the why of that behavior is clear to me at least)./cc @moozzyk
The text was updated successfully, but these errors were encountered: