-
Notifications
You must be signed in to change notification settings - Fork 34
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
Could not copy the file "<full path js file>" because it was not found #89
Comments
Yes, I experienced this as well. I am not sure if it's related the VS publishing process with npm build or Vite.AspNetCore. It does work if I update the project file like mentioned but fails subsequent tries. |
It runs two times because you have the tasks
<!-- Ensure Node environment on Build -->
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build;PublishBuildAssets" Condition=" !Exists('Assets\node_modules') ">
<!-- Install Node packages -->
<Exec Command="npm install" />
</Target>
<!-- Build the final assets -->
<Target Name="PublishBuildAssets" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Release' ">
<!-- Build the final assets -->
<Exec Command="npm run build" />
</Target> And also, I can see you are using a base directory. Your base directory should be configured to I see you have builder.Services.AddViteServices(opt =>
{
opt.Server.AutoRun = true;
opt.Base = "/dist/";
opt.Server.Https = true;
}); I also suggest you move your assets in |
I was still running into this issue on publish. You need to run Or if it still does not work, just build npm before publish so the manifest is there and ignore npm commands in Visual Studio. <!-- Ensure Node.js is installed -->
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build;Publish;PublishBuildAssets" Condition=" !Exists('node_modules') ">
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec Command="npm install" />
</Target>
<Target Name="PublishBuildAssets" BeforeTargets="Publish" Condition=" '$(Configuration)' == 'Release' ">
<Exec Command="npm run build" />
</Target> |
When I try to publish my app to a folder (trying to execute localhost to sure that It will works on production), I have the error in title for every entry file.
It's strange, because when I comment csproj, publish, uncomment csproj and publish, the publish occurs for once, but fail for next ones:
Analyzing the build log, I see that npm run prd occurs 2 times, one before build and one before publish, I think the files are recreated with another name and msbuild loses the references.
I have try like this:
But like the first one, It fails after the first time. Another thing is for the first publish, It's doesn't load js and css files.
The console shows that the manifest file doesn't exists, but exists in the folder.
I have this configuration:
Program.cs
cshtml files (this is layout.cshtml, but the others follow the same)
I try to do what the Wiki says, but I think that doesn't affect the publish process
This is after vite build
I'm using VS2022 17.8.5
dotnet 8.0.101
the app uses version 7 of sdk
The text was updated successfully, but these errors were encountered: